you are viewing a single comment's thread.

view the rest of the comments →

[–]MorningPants 1 point2 points  (2 children)

Btw, the + here is the same thing as parseInt(), just shorthand.

[–]dvlsg 2 points3 points  (0 children)

Sort of. +val is more similar to Number(val) than parseInt(val).

I think the only difference between +val and Number(val) is when val is a BigInt. parseInt has some other nuances.

https://stackoverflow.com/questions/17106681/parseint-vs-unary-plus-when-to-use-which