const privates = new WeakMap()
class Animal {
constructor(name, job) {
privates.set(this, { name, job })
console.log('I'm a total GENIUS!')
}
}
// A few lines later on the code ....
function privates() {
console.log("No, you are not. Do you remember the NO-GLOBALS rules?")
}
1. Uncaught SyntaxError: missing ) after argument list
You would have caught this one if you used highlighting:
constprivates=newWeakMap()classAnimal{constructor(name,job){privates.set(this,{name,job})console.log('I'matotalGENIUS!')
}
}
// A few lines later on the code ....
function privates() {
console.log("No, you are not. Do you remember the NO-GLOBALS rules?")
}
vs
constprivates=newWeakMap()classAnimal{constructor(name,job){privates.set(this,{name,job})console.log("I'm a total GENIUS!")}}// A few lines later on the code ....functionprivates(){console.log("No, you are not. Do you remember the NO-GLOBALS rules?")}
2. Uncaught SyntaxError: Identifier 'privates' has already been declared (pointing at the function, not the const)
Have you forgotten declaration collision? (TypeScript would also have caught it statically)
3. "globals" are fine when you are thinking in modules
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
1.
Uncaught SyntaxError: missing ) after argument list
You would have caught this one if you used highlighting:
vs
2.
Uncaught SyntaxError: Identifier 'privates' has already been declared
(pointing at the function, not theconst
)Have you forgotten declaration collision? (TypeScript would also have caught it statically)
3. "globals" are fine when you are thinking in modules