pFad - Phone/Frame/Anonymizer/Declutterfier! Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

URL: http://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/String/valueOf

>

此页面由社区从英文翻译而来。了解更多并加入 MDN Web Docs 社区。

View in English Always switch to English

String.prototype.valueOf()

基线 广泛可用

自 2015年7月 起,此特性已在主流浏览器中得到支持,可在大多数设备和浏览器版本中正常使用。

valueOf() 方法返回 String 对象的字符串值。

尝试一下

const stringObj = new String("foo");

console.log(stringObj);
// Expected output: String { "foo" }

console.log(stringObj.valueOf());
// Expected output: "foo"

语法

js
valueOf()

返回值

一个字符串,表示给定 String 对象的原始值。

描述

StringvalueOf() 方法以字符串数据类型返回 String 对象的原始值。此值等价于 String.prototype.toString()

此方法通常由 JavaScript 在内部调用,而不是在代码中显式调用。

示例

使用 valueOf()

js
const x = new String("Hello world");
console.log(x.valueOf()); // 'Hello world'

规范

规范
ECMAScript® 2027 Language Specification
# sec-string.prototype.valueof

浏览器兼容性

参见

pFad - Phonifier reborn

Pfad - The Proxy pFad © 2024 Your Company Name. All rights reserved.





Check this box to remove all script contents from the fetched content.



Check this box to remove all images from the fetched content.


Check this box to remove all CSS styles from the fetched content.


Check this box to keep images inefficiently compressed and original size.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy