개발/web

Javascript BigInt

tting 2020. 5. 13. 04:38

Javascript에서 정수 리터럴 끝에 n을 붙이면 BigInt 타입의 값을 만들 수 있다.

BigInt는 수가 커져도 실수가 아닌 정수로 다룰 수 있다.

 

typeof 1n === "bigint" // true

 

bigint는 일반 숫자와 산술연산이 불가능지만 비교 연산은가능하다.

 

alert(1n + 2); // TypeError: Cannot mix BigInt and other types

 

alert( 2n > 1n ); // true

 

challange

 

// return true to win!!
func = (x,y) => { return x == y && x !== y && x * x != 0 && y * y != 0 && ~x !== ~y}

 

 

https://ko.javascript.info/bigint?fbclid=IwAR1ISJHtCy4dm_M_Sw41mNCBxSS8BafZVvp6_l3e5NrJ0Xss8su8cqIcW8U

 

BigInt

 

ko.javascript.info