Agree with this. Number is much more noticeable at-a-glance in the source code, whereas any minor improvement in perf doesn't make any practical difference and could easily be erased or reversed by future engine optimizations in any case.
Small correction to my original comment, though — it turns out that since the introduction of the bigint data type, +x and Number(x) are no longer semantically identical: Number(1n) gives 1, whereas +1n throws an error, because bigints can only be explicitly converted to numbers, not coerced. IMO, this is another argument in favor of Number(x), as it consistently works for all data types of x, without throwing (unless you do something crazy like x = { valueOf() { throw '' } }).
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.
Agree with this.
Numberis much more noticeable at-a-glance in the source code, whereas any minor improvement in perf doesn't make any practical difference and could easily be erased or reversed by future engine optimizations in any case.Small correction to my original comment, though — it turns out that since the introduction of the bigint data type,
+xandNumber(x)are no longer semantically identical:Number(1n)gives1, whereas+1nthrows an error, because bigints can only be explicitly converted to numbers, not coerced. IMO, this is another argument in favor ofNumber(x), as it consistently works for all data types ofx, without throwing (unless you do something crazy likex = { valueOf() { throw '' } }).