zoukankan      html  css  js  c++  java
  • JS数字判定与处理

    isNaN(x):参数是否是非数字值,返回true或false

    测试
    isNaN(1.2)  //false
    isNaN("a")  //true
    isNaN("")    //false
    isNaN(null)   //false

    是否是合法的数字,数字返回false,
    isNaN(parseInt(1.2))  //false
    isNaN(parseInt("a"))  //true
    isNaN(parseFloat(""))     //true
    isNaN(parseInt(null))   //true

    Number(object):对象的值转换为数字,Date 对象返回从 1970 年 1 月 1 日至今的毫秒数
    Number(1.2)      //1.2
    Number(true)       //1
    Number(false)     //0
    Number(new Date())        //1610509620778
    Number("")       //0
    Number(null)      //0

  • 相关阅读:
    oracle学习6
    oracle学习5
    oracle学习4
    oracle学习3
    oracle的过滤与排序
    poj1064 Cable master
    poj3169 Layout
    UVA
    poj2341 Expedition
    poj3617 Best Cow Line
  • 原文地址:https://www.cnblogs.com/zenple/p/14271250.html
Copyright © 2011-2022 走看看