我有一个哈希作为 ID,我不小心使用了 parseInt()。
我想知道为什么它返回一个实际的整数 (7) 而不是 NaN
const hash = "7bb94588-4f62-4c41-a782-e5164844cc0d";
console.log(hash);
console.log(typeof hash);
console.log(parseInt(hash))
这并不是一个需要帮助的问题...但我想更好地了解 JS 的工作原理。
最佳答案
根据spec
If parseInt encounters a character that is not a numeral in the specified radix, it ignores it and all succeeding characters and returns the integer value parsed up to that point.
关于javascript - parseInt() 字符串哈希返回整数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47338982/