其他分享
首页 > 其他分享> > 变量提升

变量提升

作者:互联网

// will return a value of undefined
var myvar = "my value";

(function() {
  console.log(myvar); // undefined
  var myvar = "local value";
})();


将等同于
var myvar = "my value";
 
(function() {
  var myvar;
  console.log(myvar); // undefined
  myvar = "local value";
})();

标签:function,undefined,log,value,var,提升,myvar,变量
来源: https://www.cnblogs.com/huang131/p/12984586.html