how to check a var whether is number in js

js check var is number


Number.isInteger(NaN)
false
Number.isInteger(``)
false
Number.isInteger(0)
true
Number.isInteger(null)
false
Number.isInteger(undefined)
false

typeof === "number"

typeof NaN;
// "number" typeof undefined;
// "undefined"
typeof ``; // "string"
typeof null;
// "object"
let x = NaN;
// NaN isNaN(x);
// true isNaN(0);
// false isNaN(``);
// false isNaN(null);
// false isNaN(undefined);
// true

https://mkyong.com/javascript/check-if-variable-is-a-number-in-javascript/

https://dev.to/skptricks/check-if-variable-is-a-number-in-javascript-1f10

https://www.skptricks.com/2018/11/check-if-variable-is-number-in-js.html

https://medium.com/javascript-in-plain-english/how-to-check-for-a-number-in-javascript-8d9024708153

https://www.w3schools.com/jsref/jsref_isnan.asp


TS

https://www.typescriptlang.org/docs/handbook/type-checking-javascript-files.html


最新文章

  1. Entity Framework 教程——DBContext
  2. 关于 unsigned 型变量在计算过程中发生的事情
  3. Axis2测试webservice server以及client
  4. 应用程序缓存--manifest
  5. 收缩菜单 css变样
  6. thinkphp计划任务使用cronRun
  7. 《深入浅出 Java Concurrency》
  8. UVa 11524:In-Circle(解析几何)
  9. SQLiteParameter不能将TableName作为参数
  10. Win8控制面板快捷键
  11. Scrum教练不应兼任product owner
  12. call 方法在使用一个指定的this值和若干个指定的参数值的前提下调用某个函数或方法.
  13. 转:SQL Case when 的使用方法
  14. JS能力测评试题
  15. Windows Time服务无法启动 错误5拒绝访问
  16. 让div显示在屏幕中央的css代码段
  17. table内容强制换行
  18. 用js来实现那些数据结构03(数组篇03-排序及多维数组)
  19. 基于MVC4+EasyUI的Web开发框架形成之旅(7)--权限控制
  20. kotlin 安装 使用

热门文章

  1. Java NIO ———— Buffer 缓冲区详解 入门
  2. 类型检查和鸭子类型 Duck typing in computer programming is an application of the duck test 鸭子测试 鸭子类型 指示编译器将类的类型检查安排在运行时而不是编译时 type checking can be specified to occur at run time rather than compile time.
  3. BZOJ2120 数颜色(带修改的莫队算法)
  4. office提示“应用程序无法正常启动(0xc0000142)。请单击确认关闭应用程序”
  5. jQuery操作CheckBox的方法(选中,取消,取值)详解
  6. Java 复习整理day10
  7. MySQL特殊字符的转义处理
  8. Jenkins(3)拉取git仓库代码,执行python自动化脚本
  9. Pytest(16)随机执行测试用例pytest-random-order
  10. G - 棋盘游戏