JavaScript Variable

Working with variables in JavaScript functions
The logic at the time we finished manipulating the variables in the function, and then we get out of the function, then the variable value will be returned to the original value, although we have to change in the function.

But it all depends on the type of the variable itself, whether he's a JavaScript local variable or JavaScript global variable:

  • The variables are declared implicitly in the function (without the var keyword) will be global, which means variables can still be accessed after the execution of the function.
  • The variable is explicitly declared within the function (using the var keyword) will be local, which means only accessible from within the function, all references to the use of this variable from outside the function will cause an error (unknown variable).

When we call a function from one object, as an example, suppose a form, then we should use this keyword to make one reference to the object that is being run / in the middle of process. With these keywords we also prevented from writing the format of objects such as windows.objet1.objet2 beat around the bush .... and also at the time wanted to miss objects that are in the process to a function, we just write Function_Name(this). To be able to manipulate these objects from within a function.
As for manipulating the conditions of the object itself, we only type


Post a Comment