[ Web Proxy ]
URL:
Viewing: https://developer.mozilla.org/ja/docs/Web/JavaScript/Reference/Global_Objects/BigInt/toString [Back]  [Original]

BigInt.prototype.toString() - JavaScript | MDN

MDN Web Docs

View in English Always switch to English

BigInt.prototype.toString()

Baseline

20209

toString() BigInt (BigInt) "n"

console.log(1024n.toString());
// : "1024"

console.log(1024n.toString(2));
// : "10000000000"

console.log(1024n.toString(16));
// : "400"

js
toString()
toString(radix)

radix

2 36 10

BigInt

RangeError

toString() 2 36

BigInt Object toString() Object.prototype.toString() BigInt toString()

10 9 16 16 a f

2 2 - 2

toString() this BigInt this TypeError

BigInt [Symbol.toPrimitive]() JavaScript BigInt toString() JavaScript BigInt toString() BigInt toString() toString()

js
BigInt.prototype.toString = () => "Overridden";
console.log(`${1n}`); // "1"
console.log(`${Object(1n)}`); // "Overridden"

toString()

js
17n.toString(); // "17"
66n.toString(2); // "1000010"
254n.toString(16); // "fe"
(-10n).toString(2); // "-1010"
(-0xffn).toString(2); // "-11111111"

BigInt 0

0 BigInt 0 -0.0 JavaScript NumberIEEE

js
(-0n).toString(); // "0"
BigInt(-0).toString(); // "0"

ECMAScript 2027 LanguageSpecification
# sec-bigint.prototype.tostring


Web Proxy Viewer  |  New URL  |  Original Page