Hello
Whats the use of var in classes?
is it a function to define variables?
I tried using a variable in class without write (var) before it and it works
what is it???

Member Avatar for stbuchok

If you use a variable without declaring it, it will by default be a global variable (this is bad). JavaScript has function scope for variables rather than block scope (like most other languages). Please, for your own sake, always declare your variables.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.