📌  相关文章
📜  js 检查字符串是否为 int - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:02:04.980000             🧑  作者: Mango

代码示例4
function isNumeric(str) {

    // Check if input is string
    if (typeof str != "string")
        return false

    // Use type coercion to parse the _entirety_ of the string
    // (`parseFloat` alone does not do this).
    // Also ensure that the strings whitespaces fail
    return !isNaN(str) && 
        !isNaN(parseFloat(str)) 
}