| [ Web Proxy ] |
| Viewing: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/valueOf | [Back] [Original] |
Get to know MDN better
This feature is well established and works across many devices and browser versions. Its been available across browsers since July 2015.
The valueOf() method of String values returns this string value.
const stringObj = new String("foo");
console.log(stringObj);
// Expected output: String { "foo" }
console.log(stringObj.valueOf());
// Expected output: "foo"
valueOf()
None.
A string representing the primitive value of a given String object.
The valueOf() method of String returns the primitive value
of a String object as a string data type. This value is equivalent to
String.prototype.toString().
This method is usually called internally by JavaScript and not explicitly in code.
valueOf()const x = new String("Hello world");
console.log(x.valueOf()); // 'Hello world'
| Specification |
|---|
| ECMAScript 2027 LanguageSpecification # sec-string.prototype.valueof |
This page was last modified on Jul 10, 2025 by MDN contributors.
Stringanchor()at()big()blink()bold()charAt()charCodeAt()codePointAt()concat()endsWith()fixed()fontcolor()fontsize()includes()indexOf()isWellFormed()italics()lastIndexOf()link()localeCompare()match()matchAll()normalize()padEnd()padStart()repeat()replace()replaceAll()search()slice()small()split()startsWith()strike()sub()substr()substring()sup()toLocaleLowerCase()toLocaleUpperCase()toLowerCase()toString()toUpperCase()toWellFormed()trim()trimEnd()trimStart()valueOf()[Symbol.iterator]()Object/FunctionYour blueprint for a better internet.
Portions of this content are 19982026 by individual mozilla.org contributors. Content available under a Creative Commons license.
| Web Proxy Viewer | New URL | Original Page |