Boolean.prototype.toString()
Baseline
Widely available
This feature is well established and works across many devices and browser versions. Itโs been available across browsers since โจ2015๋ 7์โฉ.
toString()
๋ฉ์๋๋ Boolean
๊ฐ์ฒด๋ฅผ ๋ํ๋ด๋ ๋ฌธ์์ด์ ๋ฐํํฉ๋๋ค.
์๋ํด ๋ณด๊ธฐ
const flag1 = new Boolean(true);
console.log(flag1.toString());
// Expected output: "true"
const flag2 = new Boolean(1);
console.log(flag2.toString());
// Expected output: "true"
๊ตฌ๋ฌธ
js
bool.toString();
๋ฐํ ๊ฐ
Boolean
๊ฐ์ฒด๋ฅผ ๋ํ๋ด๋ ๋ฌธ์์ด.
์ค๋ช
Boolean
๊ฐ์ฒด๋ Object.prototype.toString()
๋ฉ์๋๋ฅผ ์์๋ฐ์ง ์๊ณ ์ฌ์ ์ํฉ๋๋ค. Boolean
๊ฐ์ฒด์์ toString()
๋ฉ์๋๋ ๊ฐ์ฒด์ ๋ฌธ์์ด ํํ์ ๋ฐํํฉ๋๋ค.
JavaScript๋ Boolean
์ ๋ฌธ์์ด๋ก ํํํด์ผ ํ ๋๋ ๋ฌธ์์ด ๊ฒฐํฉ์ ์ฌ์ฉํ ๋ toString()
์ ์๋์ผ๋ก ํธ์ถํฉ๋๋ค.
toString()
์ ๋ถ๋ฆฌ์ธ ๊ฐ์ฒด์ ๊ฐ์ ๋ฐ๋ผ ๋ฌธ์์ด "true
" ๋๋ "false
"๋ฅผ ๋ฐํํฉ๋๋ค.
์์
toString()
์ฌ์ฉํ๊ธฐ
js
var flag = new Boolean(true);
flag.toString(); // false
๋ช ์ธ
Specification |
---|
ECMAScriptยฎ 2026 Language Specification # sec-boolean.prototype.tostring |
๋ธ๋ผ์ฐ์ ํธํ์ฑ
Loadingโฆ