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

Number.toInteger()

我們的志工尚未將此文章翻譯為 正體中文 (繁體) 版本。加入我們,幫忙翻譯!

Obsolete
This feature is obsolete. Although it may still work in some browsers, its use is discouraged since it could be removed at any time. Try to avoid using it.

The Number.toInteger() method used to evaluate the passed value and convert it to an integer, but its implementation has been removed.

If the target value is NaN, null or undefined, 0 is returned. If the target value is false, 0 is returned and if true, 1 is returned.

Syntax

Number.toInteger(number)

Parameters

number
The value to be converted to an integer.

Examples

Using toInteger

Number.toInteger(0.1);     // 0
Number.toInteger(1);       // 1
Number.toInteger(Math.PI); // 3
Number.toInteger(null);    // 0

Specifications

Number.toInteger() was part of the draft ECMAScript 6 specification, but has been removed on August 23, 2013 in Draft Rev 17.

Browser compatibility

Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari
Basic support No support No support [1] No support No support No support
Feature Android Chrome for Android Firefox Mobile (Gecko) IE Mobile Opera Mobile Safari Mobile
Basic support No support No support No support [1] No support No support No support

[1] This feature was supported from Firefox 16 to 32.

See also

文件標籤與貢獻者

 此頁面的貢獻者: fscholz, Mingun, teoli
 最近更新: fscholz,