js functions and values of the parameters of the problem and this

Before talking about the knowledge we must first understand the following
variable assignment is to actually assign the value of a variable to another variable in memory, and the value of this variable memory may be basic types, it may address
the types of variables:
* Basic Types : memory is stored in the variable basic types of data.
* Reference types: memory is stored in the variable address.

在js调用函数时,传递变量参数是只传递
var a=1;
function b(a) { 
    a++;
 }
 b(a);
 console.log(a);
 在这个例子中调用b函数时只是把a的值1传递给了b函数中的变量a,而全局变量中的a没有任何变化。

Several went on to say this case the value of
1, when the direct call function, this is the window
2, when the method is called to form, this method is to call the object
3, when calling to construct a functional form, this is a newly created It objects
4, when the call to call and apply form, this is the object specified

Guess you like

Origin blog.csdn.net/weixin_42322521/article/details/91508984