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 July 2015.

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® 2025 Language Specification
# sec-boolean.prototype.tostring

브라우저 호환성

Report problems with this compatibility data on GitHub
desktopmobileserver
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
Deno
Node.js
toString

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support

같이 보기