看JavaScript一道题

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/u014465934/article/details/88934610

看一道题:

function test(arg){
	console.log(arg);
	var arg = "hello";
	function arg(){
		console.log('hello world');
	}
	console.log(arg);
}
test('hi')

//输出
ƒ arg(){
		console.log('hello world');
	}
hello

function test(arg){
	console.log(arg);
	var arg = "hello";
	
	
}
test('hi')
//输出
hi

VO按照如下顺序填充:
1.函数参数(若未传入,初始化该参数值为undefined)
2.函数声明(若发生命名冲突,会覆盖)
3.变量声明(初始化变量值为undefined,若发生命名冲突,会忽略。)

总结:函数声明>函数参数>变量声明

猜你喜欢

转载自blog.csdn.net/u014465934/article/details/88934610