> ['1', '4294967295', '10'].map(x=>~~+x) (3) [1, -1, 10]
Bitwise NOT (~):
The operands are converted to 32-bit integers and expressed by a series of bits (zeroes and ones). Numbers with more than 32 bits get their most significant bits discarded.
Unsigned right shift (>>>):
Unlike the other bitwise operators, zero-fill right shift returns an unsigned 32-bit integer.
Know the limitations of your tools.
Integers and shift operators in JavaScript
> ['1.1', '9007199254740991.6', '10.9'].map(n => parseInt(n)) (3) [1, 9007199254740991, 10]
I know all that, but for the purposes of a simple string -> integer parser, this works just fine
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Bitwise NOT (~):
Unsigned right shift (>>>):
Know the limitations of your tools.
Integers and shift operators in JavaScript
I know all that, but for the purposes of a simple string -> integer parser, this works just fine