I realize this isn't strictly a Node-RED question, but it came up in designing a validation function for a custom node. I want to test whether a text input represents an integer. I get these results:
let v = '3'
node.warn(Number.isInteger(v)) // false
node.warn(Number.isInteger(Number.parseFloat(v))) // true
Is there a less silly-looking way to write the third line?
[EDIT] OK, I just realized I can get away with Number.isInteger(Number(v))
. Still, for a language that is so careless with type conversion, I expected less...