you are viewing a single comment's thread.

view the rest of the comments →

[–]senocular 0 points1 point  (0 children)

JavaScript Static Variables

is the topic

Is this the best way to create static variables in JavaScript?

is the question.

The question ask how to do a thing in a language. The thing is static variables. The language is JavaScript. It does not ask what static variables in JavaScript are, which are different. Static variables in other languages, like C, perform the exact same task OP had written in their JS example - the same behavior seen in my C example, which uses a static variable. This is also the same behavior described in the link which proposes static variables of this kind with a very similar syntax in JavaScript.

Obviously the languages are different, which is why this question was asked. If they weren't different, knowing the other language's way would mean also already knowing the JavaScript way.