loading...

re: Why does (class instance).$name result in the name of the most recent classname and not the actual name? VIEW POST

FULL DISCUSSION
 

You don't have a var/let/const in front of classInstance so it's a global window.classInstance not the closure you think it is. It's getting overwritten etc.

'use strict' can be your friend :)

 

Ah shit, why is it always the let var const thing that always trips me the fuck up?? But, how do I use strict mode? Is there any rule about where I start using strict mode? Also, tysm

 

If you stick the string

'use strict'

as the first line of a file - it's in strict mode and it should tell you that you are assigning to a global without defining it.

Other choice is use a linter like eslint can help in these circumstances.

code of conduct - report abuse