Variable lift and enhance the function

Enhance the function takes precedence over the variable lift and is not covered variable but will be assigned to cover variable

var b
	function b(){console.log("我是一个函数")}
	console.log(typeof b)   //function
	console.log(b())  //“我是一个函数”  ‘undefined’
	console.log("----------------")
	b = 4
	console.log(b)   //4
	console.log(b())  //b is not a function
 //面试题2
	if(!(z in window)){
	    var z = 1
	}
	console.log("z是多少---",z)  //undefined

	var c = 1
	function c(c){
	    console.log("c是多少---",c)
		var c = 3
	}
	c(2)   //c is not a function

 

Published 54 original articles · won praise 8 · views 70000 +

Guess you like

Origin blog.csdn.net/yang295242361/article/details/101675508