I used to be an actor, but programming jobs are easier to come by. I've been doing this now for 11 years. I focus on pixels and experience, especially on iOS and the web.
I agree with Lloyd here about using the single "+" instead of writing "parseInt". While it's a fun trick to know about, this would also be a thing I would flag (or worse, miss) in a PR and ask to be changed to the more understandable "parseInt".
Economy of expression or terseness isn't more valuable than understandability, otherwise we'd all minify our code before committing it.
parseInt(s) is not a good example, it works very differently and has a radix issue... parseFloat(s) is closer, but still ignores any junk at the end of the string... I usually call Number(s) (not new Number(x), which has even worse problems), which is explicit and behaves just like unary + operator... Even this has a surprising issue of an empty string evaluating to 0...
Do not confuse Economy of Expression with Minification because the intention of the former is to increase clarity and ease of understanding. Sometimes fewer words express more clearly what is intended and longer sentences are a means of hiding the real crux of the message.
Some comments have been hidden by the post's author - find out more
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.
I agree with Lloyd here about using the single "+" instead of writing "parseInt". While it's a fun trick to know about, this would also be a thing I would flag (or worse, miss) in a PR and ask to be changed to the more understandable "parseInt".
Economy of expression or terseness isn't more valuable than understandability, otherwise we'd all minify our code before committing it.
parseInt(s)
is not a good example, it works very differently and has a radix issue...parseFloat(s)
is closer, but still ignores any junk at the end of the string... I usually callNumber(s)
(notnew Number(x)
, which has even worse problems), which is explicit and behaves just like unary+
operator... Even this has a surprising issue of an empty string evaluating to0
...Do not confuse Economy of Expression with Minification because the intention of the former is to increase clarity and ease of understanding. Sometimes fewer words express more clearly what is intended and longer sentences are a means of hiding the real crux of the message.