javascript - Define global variable inside a function -


Is it possible to define global variables within a function like a dragon?

For example -

In Python

  def testFunc (): global testVar testVar + = 1   < P> Is there a way to define testvar global in javascript function?   

Just ignore the keyword var .

  function testFunc () {testVar = 1; // `testVar` is now a global winch)  Note:  In the Python version of your code, you can not  define  a global Variables You are referring to the variable  testVar  defined in the global area. Quoted from  

Assigns a value for an undeclared variable, declares a global variable (it is now the property of the global object) < / blockquote>

Comments

Popular posts from this blog

python - Writing Greek in matplotlib labels, titles -

c# - LINQ to Entities does not recognize the method 'Int32 IndexOf(System.String, System.StringComparison)' method -

Pygame memory leak with transform.flip -