[ Web Proxy ]
URL:
Viewing: https://developer.mozilla.org/ko/docs/Web/JavaScript/Guide/Data_structures#bigint_type [Back]  [Original]

JavaScript - JavaScript | MDN

This page was translated from English by the community. Learn more and join the MDN Web Docs community.

View in English Always switch to English

JavaScript

, . JavaScript . .

, .

In this article

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

, , (: , ) (footgun) . BigInts , JavaScript .

(Primitive values)

Object . ' ' .

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

null undefined , . , Number toExponential() . , JavaScript . null undefined , TypeError .

Type typeof return value Object wrapper
Null "object" N/A
Undefined "undefined" N/A
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" ). undefined.

null . prototype chain . , Object.getPrototypeOf(), Object.create() undefined null .

null , undefined . undefined .

Boolean

Boolean true false .

, if...else, while , .

Number

Number 64 IEEE 754 . 2-1074 (Number.MIN_VALUE) 21024 (Number.MAX_VALUE) , -2-1074 -21024 , -(253 1) (Number.MIN_SAFE_INTEGER) 253 1 (Number.MAX_SAFE_INTEGER) . , JavaScript . . Number.isSafeInteger() .

(2-1074 to 21024) .

+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

NaN ("Not a Number") , . , "NaN" JavaScript .

" " , JavaScript . 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; // 9007199254740992n 9007199254740993n   false.

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

+, *, -, **, % BigInt . >>> . BigInt Number .

BigInt , , BigInt . , . TypeError BigInt .

String

String , UTF-16 16 . String String . 0, 1 . String UTF-16 , . String .

JavaScript String . , String . String String String . , .

" "

, .

, . . , ( JavaScript ) . . , ... .

. .

Symbol

Symbol ( ) . "" . .

. JavaScript . Functions callable .

JavaScript . , . - . strings symbols . .

. ''(attribute) . JavaScript , Object.defineProperty() , Object.getOwnPropertyDescriptor() .

Object.defineProperty() .

, .

value

get . JavaScript .

writable

.

enumerable

A boolean value indicating if the property can be enumerated by a for...in loop. See also Enumerability and ownership of properties for how enumerability interacts with other functions and syntaxes.

for...in . .

configurable

, , .

(get, set) .

: '' '' . JavaScript , .

.

get

get . getters . undefined .

set

. . setters . undefined .

enumerable

for...in . .

configurable

, , .

prototype null . , [[Prototype]] . [[Prototype]] .

- , . , . , Map . Map - Map .

JavaScript Date .

:

length .

, Array.prototype . , indexOf() , push() . .

(Typed Arrays) , . "( )Typed Array" Int8Array, Float32Array . typed array . Typed Array ArrayBuffer DataView .

: Maps, Sets, WeakMaps, WeakSets

. Set WeakSet , Map WeakMap .

Map Set . (<, '' ) , , . (WeakMap ) .

DOM data-* , . Map WeakMap .

WeakMap WeakSet , . .

: JSON

JSON(JavaScript Object Notation) , JavaScript . JSON . JSON .

JavaScript . .

, JavaScript . , , . , JavaScript .

, . string, number BigInt . .

  • Date() Date , String String , .
  • + , String String .
  • == , , .

, . [@@toPrimitive]() ( "default" ), valueOf(), toString() . toString() valueOf() , , string .

[@@toPrimitive]() , . TypeError . valueOf() toString() , . , TypeError . .

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

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

[@@toPrimitive]() . valueOf() , . [@@toPrimitive]() . Date Symbol [@@toPrimitive]() . Date.prototype[@@toPrimitive]() "default" "string" , Symbol.prototype[@@toPrimitive]() (symbol) .

Number BigInt . BigInt(: Array.prototype.slice()) . , . BigInt .

BigInt TypeError (number coercion) . Number BigInt , . .

Null, Undefined Symbol . string , (boolean) .

, .

  • : [@@toPrimitive]("default") valueOf() toString()
  • , number coercion, BigInt coercion: [@@toPrimitive]("number") valueOf() toString()
  • : [@@toPrimitive]("string") toString() valueOf()

, [@@toPrimitive]() , , valueOf toString . , . .


Web Proxy Viewer  |  New URL  |  Original Page