What is the difference between var x=1 and x = 1 in NodeJs
This question already has an answer here:
'var x = 3' will create a variable within the current scope. Given this is declared in a function, x will not be available outside it, unless explicitly returned.
'x = 3' will create a variable within the global scope. Thus, any other code can access and alter its value. It's generally a bad practice to use variables in a global scope.
链接地址: http://www.djcxy.com/p/17362.html