返回字符串 语法 string.valueOf() 参数 此方法没有参数。 返回值 返回字符串值 备注 在下面的示例中,字符串对象与返回值相同。 var str = "every good boy does fine"; var strStr = str.valueOf(); if (str === strStr) document.write("same"); else document.write("different"); // Output: // same 必备条件 在以下文档模式中受支持:怪异模式、Internet Explorer 6标准模式、Internet Explorer 7标准模式、Internet Explorer 8标准模式、Internet Explorer 9标准模式、Internet Explorer 10标准模式、Internet Explorer 11标
为number的类返回原型的引用。 语法 number.prototype 备注 number参数是数字的名称。 Use the prototype property to provide a base set of functionality to a class of objects. New instances of an object "inherit" the behavior of the prototype assigned to that object. For example, to add a method to the Number object that returns the number of (integer) digits, declare the function, add it to Number.prototype, and then use it.
指定创建一个数字的函数。 语法 number.constructor 备注 必需的number是字符串的名称。 constructor属性是每个具有原型的对象的原型成员。这包括Global和Math对象之外所有内部JavaScript对象。constructor属性包含了对某种函数的引用,此种函数构造了特定对象的实例。 示例 下面的示例阐释了constructor属性的用法。 var num = new Number(); if (num.constructor == Number) document.write("Object is a Number."); else document.write("Object is not a Number."); // Output: // Object is a Number. 必备条件 在以下文档模式中受支持:怪异模式、Internet Exp
返回一个布尔值,指示值是否为整数。 语法 Number.isInteger(numValue) 返回值 如果值是整数则返回true,否则返回false。 备注 必备条件 Microsoft Edge中受支持。应用商店应用(Windows 10 上的 Microsoft Edge)中也受支持。请参阅版本信息。 在以下文档模式中不受支持:怪异模式、Internet Explorer 6 标准模式、Internet Explorer 7 标准模式、Internet Explorer 8 标准模式、Internet Explorer 9 标准模式、Internet Explorer 10 标准模式和 Internet Explorer 11 标准模式。在 Windows 8.1 中不受支持。 Applies To: Number Object 示例 // Returns true Number.i
一个表示任何类型的数字对象。所有JavaScript数字均为64位浮点数。 语法 numObj = new Number(value) 参数 numObj 必要参数。Number对象分析到的变量名称。 value 必要参数。数值。 备注 变量设置为数值(例如var num = 255.336;)时,JavaScript创建Number对象。很少需要显式创建Number对象。 除了从Object继承的属性和方法,Number对象自然还具有属性和方法。在某些情况下,数字将转换为字符串,例如在向字符串添加或串联数字时,以及在使用toString方法执行这些操作时。欲进一步了解,请参阅加法运算符 (+)。 JavaScript具有多个数字常量。欲获取完整列表,请参阅Number 常量。 必备条件 在以下文档模式中受支持:怪异模式、Internet Explorer 6标准模式、Internet E
返回指定对象的原始值。 语法 mapObj.valueOf() 参数 mapObj 必要参数。Map对象。 属性值、返回值 返回Map实例。 必备条件 在Internet Explorer 11标准文档模式下支持此项。此外,也在应用商店应用(Windows 8.1和Windows Phone 8.1)中受支持。请参阅版本信息。 在以下文档模式中不受支持:怪异模式、Internet Explorer 6标准模式、Internet Explorer 7标准模式、Internet Explorer 8标准模式、Internet Explorer 9标准模式和Internet Explorer 10标准模式。在Windows 8中不受支持。
返回映射的字符串表达形式。 语法 mapObj.toString() 参数 mapObj 必要参数。Map对象。 属性值、返回值 映射的字符串表示形式。 异常 必备条件 在Internet Explorer 11标准文档模式下支持此项。此外,也在应用商店应用(Windows 8.1和Windows Phone 8.1)中受支持。请参阅版本信息。 在以下文档模式中不受支持:怪异模式、Internet Explorer 6标准模式、Internet Explorer 7标准模式、Internet Explorer 8标准模式、Internet Explorer 9标准模式和Internet Explorer 10标准模式。在Windows 8中不受支持。
从映射中删除所有元素。 语法 mapObj.clear() 参数 mapObj 必要参数。要清空的映射。 必备条件 在Internet Explorer 11标准文档模式下支持此项。此外,也在应用商店应用(Windows 8.1和Windows Phone 8.1)中受支持。请参阅版本信息。 在以下文档模式中不受支持:怪异模式、Internet Explorer 6标准模式、Internet Explorer 7标准模式、Internet Explorer 8标准模式、Internet Explorer 9标准模式和Internet Explorer 10标准模式。在Windows 8中不受支持。
对变量值与表达式值执行按位“或”运算,并将结果赋给该变量。 语法 result |= expression 参数 result Any variable. expression Any expression. 备注 使用此运算符与指定以下内容完全相同: result = result | expression |=运算符查看result和expression的值的二进制表示形式,并对其执行按位“或”运算。该运算的结果如下所示: 0101 (result) 1100 (expression) ---- 1101 (output) 任何时候,只要两个表达式中的一个表达式的某位为1,则结果中的该位为1。否则,结果中的该位为0。 必备条件 在以下文档模式中受支持:怪异模式、Internet Explorer 6标准模式、Internet Explorer 7标准模式、Internet Explor