[ Web Proxy ]
URL:
Viewing: https://developer.mozilla.org/ko/docs/Web/JavaScript/Reference/Global_Objects/String/String [Back]  [Original]

String() - 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

String()

Baseline Widely available

This feature is well established and works across many devices and browser versions. Its been available across browsers since 2015 7.

String() String . String .

In this article

js
new String(thing)
String(thing)

: String() new . . .

thing

.

String() (new ) . Symbol "Symbol(description)" , description description.

String() (new ) value String .

: String .

String String

String String .

js
const a = new String("Hello world"); // a === "Hello world"  false
const b = String("Hello world"); // b === "Hello world"  true 
a instanceof String; // true
b instanceof String; // false
typeof a; // "object"
typeof b; // "string"

( ) . ( ) .

String()

String() . .

js
const sym = Symbol("example");
`${sym}`; // TypeError: Cannot convert a Symbol value to a string
"" + sym; // TypeError: Cannot convert a Symbol value to a string
"".concat(sym); // TypeError: Cannot convert a Symbol value to a string
js
const sym = Symbol("example");
String(sym); // "Symbol(example)"

Specification
ECMAScript 2027 LanguageSpecification
# sec-string-constructor


Web Proxy Viewer  |  New URL  |  Original Page