Apply your JS skills to key Mozilla projects as an MDN Fellow! http://mzl.la/MDNFellowship

mozilla
Your Search Results

    Number.toInteger()

    この記事はまだ日本語に翻訳されていません。MDN の翻訳はボランティアによって行われています。是非 MDN に登録し、私たちの力になって下さい。

    Obsolete since Gecko 33 (Firefox 33 / Thunderbird 33 / SeaMonkey 2.30)
    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.

    Non-standard
    This feature is non-standard and is not on a standards track. Do not use it on production sites facing the Web: it will not work for every user. There may also be large incompatibilities between implementations and the behavior may change in the future.

    Summary

    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

    Example: Using toInteger

    Alert of some test values:

    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 Not supported Firefox 16 to 32 Not supported Not supported Not supported
    Feature Android Chrome for Android Firefox Mobile (Gecko) IE Mobile Opera Mobile Safari Mobile
    Basic support Not supported Not supported Firefox 16 to 32 Not supported Not supported Not supported

    See also

    • The Number object it belongs to.

    ドキュメントのタグと貢献者

    Contributors to this page: Mingun, fscholz, teoli
    最終更新者: Mingun,
    サイドバーを隠す