Js understood that local variables and global variables

1, local and global variables in understanding the practical application:

First, we must implement every function call data, before proceeding on the basis of the function, the use of global variables, if you want to refresh, use local variables.

E.g:

I want to add i CPC 100;

So, the function as follows:

var i = 0;

function add(){

 i=i+100;

}

Then, when called, call every time, plus 100 on the basis of the original.

100   200   300  ....

When paging, only thought of before and after the strip interactive data back and forth between traditional values ​​and the foreground to the background, ignored this point. Record it.

Guess you like

Origin www.cnblogs.com/ciscolee/p/11238426.html