how to check a var whether is number in js
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
本文首发于博客园,作者:xgqfrms,原文链接:https://www.cnblogs.com/xgqfrms/p/12528847.html
未经授权禁止转载,违者必究!