NoteDeep

数据类型

最新的 ECMAScript 标准定义了 7 种数据类型:
  • 6 种原始类型:
  • Boolean
  • Null
  • Undefined
  • Number
  • String
  • Symbol (ECMAScript 6 新定义)
  • 和引用类型 Object

typeof null // "object" (因为一些以前的原因而不是'null')
typeof undefined // "undefined"
null === undefined // false
null == undefined // true
null === null // true
null == null // true
!null //true
isNaN(1 + null) // false
isNaN(1 + undefined) // true

严格模式

未指定环境对象而调用函数,this不会转型为window。除非明确把函数添加到某个对象,或者调用apply或call,否则this的值都将是undefined.
"use strict";
var color="red";
function a(){
console.log(window.color);
console.log(this.color);
}
a();
//red
//报错


var color="red";
function a(){
console.log(window.color);
console.log(this.color);
}
a();
// red
// red


评论列表

    数据类型
    严格模式