This page was translated from English by the community.Learn more and join the MDN Web Docs community.
String.prototype.valueOf()
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월.
In this article
시도해 보기
const stringObj = new String("foo");console.log(stringObj);// Expected output: String { "foo" }console.log(stringObj.valueOf());// Expected output: "foo"구문
js
valueOf()매개변수
없음.
반환 값
주어진String 객체의 원시 값을 나타내는 문자열.
설명
String 의valueOf() 메서드는String 객체의 원시 값을 문자열 데이터 타입으로 반환 합니다. 이 값은String.prototype.toString().과 동일합니다.
이 메서드는 보통 JavaScript에 의해 내부적으로 호출되며, 코드에서 명시적으로 사용하지는 않습니다.
예제
>valueOf() 사용하기
js
const x = new String("Hello world");console.log(x.valueOf()); // 'Hello world'명세서
| Specification |
|---|
| ECMAScript® 2026 Language Specification> # sec-string.prototype.valueof> |