There's nothing wrong in using it, and yeah I agree in part. But you can't expect developers to be 100% concentrated and careful 100% of the time, we're humans and as humans we might have a bad day, we might have not slept well, etc... A new developer might not yet know how the unary operator work, it's not intuitive at all. You already need a good knowledge of the language.
So if I have the choice I will use other options before the unary operator to convert strings to numbers. This way we reduce the possibilities of a miss. And I usually prefer to make my code literal, ie using Number('1') or parseInt('1') instead of +1. It might be a personal preference, but I really think it can be beneficial to not use it if it can be omitted.
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.
There's nothing wrong in using it, and yeah I agree in part. But you can't expect developers to be 100% concentrated and careful 100% of the time, we're humans and as humans we might have a bad day, we might have not slept well, etc... A new developer might not yet know how the unary operator work, it's not intuitive at all. You already need a good knowledge of the language.
So if I have the choice I will use other options before the unary operator to convert strings to numbers. This way we reduce the possibilities of a miss. And I usually prefer to make my code literal, ie using
Number('1')
orparseInt('1')
instead of+1
. It might be a personal preference, but I really think it can be beneficial to not use it if it can be omitted.