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

String() - JavaScript | MDN

MDN Web Docs

View in English Always switch to English

String()

Baseline

20157

String String

js
new String(thing)
String(thing)

: String() new

thing

String() new value "Symbol(description)" description

String new value String

: String

String String

String String

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

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

ECMAScript 2027 LanguageSpecification
# sec-string-constructor


Web Proxy Viewer  |  New URL  |  Original Page