<Exploring ES6> 读书笔记 - New number and Math features

  1. New integer literals, 直接可以二进制, 八进制, 十六进制了

    0xFF // ES5: hexadecimal
    255
    0b11 // ES6: binary
    3
    0o10 // ES6: octal
    8

  2. New Number properties

    Number.isInteger(num)
    Number.isSafeInteger(number)
    Number.MIN_SAFE_INTEGER
    Number.MAX_SAFE_INTEGER
    Number.isNaN(num)
    Number.isFinite
    Number.parseFloat
    Number.parseInt

  3. New Math methods

    Math.sign(-8) // -1
    Math.trunc(3.1)
    Math.log10(100)

标签: none

添加新评论