其实还是this指向规则问题
1、
var x = 10;
function fn() {
console.log(x);
}
function show(f) {
var x = 20;
f();
}
show(fn);//10
2、
var fn = function() {
console.log(fn);
}
fn()
var obj = {
fn2: function() {
console.log(fn2);
}
}
obj.fn2()
var fn = function() {
console.log(fn);
}
fn()
var obj = {
fn2: function() {
console.log(this.fn2);
}
}
obj.fn2()
3、
var num1=12;
var num2=13
function fun(num,num1){
/*
var num;
var num1;
*/
num=100;
num1=100;
num2=100;
console.log(num);
console.log(num1);
console.log(num2);
}
fun(num1,num2);
console.log(num1);
console.log(num2);
console.log(num);