06-05 前端 21-25

21.看javascript代码写结果:

var name = '张三'; 
function func(){
  var name = '李四';
  function inner(){
        console.log(name)
  }
	return inner;
}
var ret = func();
ret()

执行结果:李四

22.看javascript代码写结果:

function main(){
   if(1==1){
			var name = "张三"; 
   }
   console.log(name);
}

执行结果:undefind

23.看javascript代码写结果:

var name = "张三";
function func(){
  var name = "李四";
  function inner(){
    var name = "王五";
    console.log(name);
  }
  return inner();
}
func();

执行结果:王五

24.看javascript代码写结果:

function func(){
	console.log(name);
  var name = "DSB";
}

执行结果:undefined

25.看javascript代码写结果:

var name = "张三"; 
function Foo(){
	this.name = "李四";
  this.func = function(){
		console.log(this.name);
  }
}
var obj = new Foo();
obj.func();

执行结果:李四

posted @ 2019-10-23 19:25  小猿取经-林海峰老师  阅读(493)  评论(1编辑  收藏  举报