I am learning javascript . And I noted that the instructor was making variables in two ways . first was (for example):
var name ="Any string here";
and second method was simply writing the variable name without writing var first :
name="Any string here";
And the result was same . So , is there any difference between these two ?. Which one is better to use ?
离开了var
使其成为一个全局变量,所以如果你有name
多个地方的代码,他们会互相覆盖。
var
before variable declaration. var
. strict mode
using variable without declaration will cause Exception
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.