string.toString
toString()
๋ฉ์๋๋ ์ง์ ๋ ๊ฐ์ฒด๋ฅผ ๋ํ๋ด๋ ๋ฌธ์์ด์ ๋ฐํํ๋ค.
const stringObj = new String('foo');
stringObj; // String {"foo"}
stringObj.toString(); // "foo"
Syntax
str.toString()
Return value
ํธ์ถ๋ ๊ฐ์ฒด๋ฅผ ๋ํ๋ด๋ ๋ฌธ์์ด
Description
String
object๋ Object
object์ toString()
๋ฉ์๋๋ฅผ ์ฌ์ ์ํ๋ค. ์ด๊ฒ์ Object.prototype.toString()
์ ์์ํ์ง ์๋๋ค. String
object์ ๊ฒฝ์ฐ, toString()
๋ฉ์๋๋ ํด๋น object๋ฅผ ๋ํ๋ด๋ ๋ฌธ์์ด์ ๋ฐํํ๋ค. (Stirng.prototype.valueOf()
์ ๋์ผ)
Examples
toString() ์ฌ์ฉ
const x = new String('Hello world');
x.toString(); // "Hello world"
Last updated
Was this helpful?