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

Pass DB Connection parameters to a Kettle a.k.a PDI table Input step dynamically from Excel -

multithreading - PhantomJS-Node in a for Loop -

c++ - MATLAB .m file to .mex file using Matlab Compiler -