typeof 用 二进制位来标识JavaScript中的值。
000表示对象,object
010表示浮点数,001表示整数,(都是返回number类型)
100表示字符串,
110表示布尔值,
-2^30表示undefined,
null是64个0组成的二进制。 由于null全0表示,所以会被误判为对象类型。
js中数据类型分为基本数据类型
和引用数据类型
。
基本数据类型又包括:
- number 数字
- string 字符串
- boolean 布尔
- null 空对象
- undefined 未定义
- symbol 唯一值
引用数据类型:object
4.2 ECMAScript Overview ECMAScript is object-based: basic language and host facilities are provided by objects, and an ECMAScript program is a cluster of communicating objects. In ECMAScript, an object is a collection of zero or more properties each with attributes that determine how each property can be used—for example, when the Writable attribute for a property is set to false, any attempt by executed ECMAScript code to assign a different value to the property fails. Properties are containers that hold other objects, primitive values, or functions. A primitive value is a member of one of the following built-in types: Undefined, Null, Boolean, Number, String, and Symbol; an object is a member of the built-in type Object; and a function is a callable object. A function that is associated with an object via a property is called a method.
ECMAScript是基于对象的:基本语言和主机设施是由对象提供的,而ECMAScript程序是通信对象的集群。 在ECMAScript中,对象是0个或多个属性的集合,每个属性都具有决定如何使用每个属性的属性——例如, 当属性的可写属性被设置为false时,执行ECMAScript代码为属性分配不同值的任何尝试都将失败。 属性是容纳其他对象、基本值或函数的容器。原始值是以下内置类型之一的成员: 未定义、Null、布尔、数字、字符串和符号;对象是内置类型对象的成员; 函数是可调用对象。通过属性与对象关联的函数称为方法.