[ Web Proxy ]
URL:
Viewing: https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Guide/Data_structures [Back]  [Original]

JavaScript - JavaScript | MDN

MDN Web Docs

View in English Always switch to English

JavaScript

JavaScript

JavaScript JavaScript

js
let foo = 42; // foo 
foo = "bar"; // foo 
foo = true; // foo 

JavaScript

js
const foo = 42; // foo 
const result = foo + "1"; // JavaScript  foo 
console.log(result); // 421

symbol BigIntJavaScript

Object

null typeof typeof null "object" === null null

null undefined Number toExponential() JavaScript null undefined TypeError

typeof
Null "object"
Undefined "undefined"
Boolean "boolean" Boolean
Number "number" Number
BigInt "bigint" BigInt
String "string" String
Symbol "symbol" Symbol

Null

Null null

Undefined

Undefined undefined

undefined null typeof null === "object"JavaScript undefined

null Object.getPrototypeOf()Object.create() null undefined

null undefined undefined

Boolean

Boolean true false

if...elsewhile

Number

Number IEEE 754 64 2-1074Number.MIN_VALUE 21023 (2 - 2-52)Number.MAX_VALUE -(253 1)Number.MIN_SAFE_INTEGER 253 1Number.MAX_SAFE_INTEGERJavaScript Number.isSafeInteger()

+Infinity -Infinity Number.POSITIVE_INFINITY Number.NEGATIVE_INFINITY

Number -0 +0 0 0 +0 +0 === -0 true 0

js
console.log(42 / +0); // Infinity
console.log(42 / -0); // -Infinity

NaNNot a Number JavaScript

number JavaScript number 32

JavaScript

BigInt

BigInt JavaScript BigInt Number Number.MAX_SAFE_INTEGER

BigInt n BigInt()

Number.MAX_SAFE_INTEGER

js
// BigInt
const x = BigInt(Number.MAX_SAFE_INTEGER); // 9007199254740991n
x + 1n === x + 2n; // false 9007199254740992n  9007199254740993n 

// Number
Number.MAX_SAFE_INTEGER + 1 === Number.MAX_SAFE_INTEGER + 2; // true 9007199254740992

BigInt +*-** % >>>BigInt Number

BigInt number BigInt BigInt number TypeError

String

String UTF-16 16 0 1 UTF-16 Unicode String

JavaScript

JavaScript

Symbol

Symbol Symbol symbol

Object

JavaScript

JavaScript symbol

JavaScript Object.defineProperty() Object.getOwnPropertyDescriptor() Object.defineProperty()

value

get JavaScript

writable

enumerable

for...in

configurable

get set

JavaScript

get

get getter undefined

set

setter undefined

enumerable

for...in

configurable

null [[Prototype]] [[Prototype]]

map Map Map map

Date

JavaScript Date

length

Array.prototype indexOf() push()

Int8ArrayFloat32Array ArrayBuffer DataView

MapSetWeakMapWeakSet

Set WeakSet Map WeakMap

Map Set < WeakMap

DOM data-* Map WeakMap

WeakMap WeakSet symbol

JSON

JSONJavaScript Object Notation JavaScriptJSON JSON

JavaScript

JavaScript JavaScript JavaScript

stringnumber BigInt

[Symbol.toPrimitive]() default hint valueOf() toString() toString() valueOf() number

[Symbol.toPrimitive]() TypeError valueOf() toString() TypeError

js
console.log({} + []); // "[object Object]"

{} [] [Symbol.toPrimitive]() {} [] Object.prototype.valueOf valueOf() toString() {}.toString() "[object Object]" [].toString() """[object Object]"

[Symbol.toPrimitive]() number valueOf() [Symbol.toPrimitive]() Date Symbol [Symbol.toPrimitive]() Date.prototype[Symbol.toPrimitive]() "string" "default" hint Symbol.prototype[Symbol.toPrimitive]() hint symbol

Number BigIntJavaScript number BigInt Array.prototype.slice() number number BigInt

number BigInt TypeError number BigInt number

NullUndefined Symbol

  • [Symbol.toPrimitive]("default") valueOf() toString()
  • number BigInt [Symbol.toPrimitive]("number") valueOf() toString()
  • [Symbol.toPrimitive]("string") toString() valueOf()

[Symbol.toPrimitive]() valueOf toString


Web Proxy Viewer  |  New URL  |  Original Page