this指向:
类中的所有代码都会在严格模式下执行,严格模式下其中一个特点就是,函数的this 不再是window,而是undefined
js中:
null 与 undefined
undefined: 表示‘无’的原始值, NaN
1. 已声明,未赋值
例:
let o;
console.log(o); //会出现undefined
2. 对象的某个属性不存在,
例:
let obj={}
Console.log(obj.a). // 会出现undefined
3. 传参的时候,函数调用时少传了一个参数
例:
function fn(a,b){
console.log(alb)
}
fn(1); // 执行函数会出现undefined
4. 函数的默认返回值
例:
function abc(){
console.log(‘max’)
}
console.log(abc()); // 执行结果会出现undefined
如果改写如:
function abc(){
console.log(‘max’);
return 222
}
console.log(abc()); // 此时控制台就会打印出222
Null: 表示为’无‘ 对象 0
-
手动释放内存
-
作为函数的参数(此参数不是对象)
-
原型链的顶端