Please note, this is a STATIC archive of website developer.mozilla.org from November 2016, cach3.com does not collect or store any user information, there is no "phishing" involved.

Number.prototype.valueOf()

概述

valueOf() 方法返回一个被 Number 对象包装的原始值。

语法

numObj.valueOf()

参数

描述

该方法通常是由 JavaScript 引擎在内部隐式调用的,而不是由用户在代码中显式调用的。

示例

var numObj = new Number(10);
console.log(typeof numObj); // object

var num = numObj.valueOf();
console.log(num);           // 10
console.log(typeof num);    // number

规范

规范名称 规范状态 备注
ECMAScript 1st Edition. Standard  
ECMAScript 5.1 (ECMA-262)
Number.prototype.valueOf
Standard  
ECMAScript 6 (ECMA-262)
Number.prototype.valueOf
Release Candidate  

浏览器兼容性

Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari
Basic support (Yes) (Yes) (Yes) (Yes) (Yes)
Feature Android Chrome for Android Firefox Mobile (Gecko) IE Mobile Opera Mobile Safari Mobile
Basic support (Yes) (Yes) (Yes) (Yes) (Yes) (Yes)

相关链接

文档标签和贡献者

标签: 
 此页面的贡献者: ziyunfei, yenshen, AlexChao
 最后编辑者: ziyunfei,