Re:JSFuck (2012)
by idolaspecus on Sunday September 26, 2021 @12:02AM
(#28658299)
This is in my opinion actually a decent interview question. If you know JS in detail, if you know how the "+" operator works, it's a super easy question. If you don't know JS in detail, if you don't know how the "+" operator works, it's pretty tough. If you want an engineer who knows JS in detail, asking this question can be valuable.
[ Parent
| on HN ]
Re:JSFuck (2012)
by colordrops on Sunday September 26, 2021 @03:03AM
(#28658989)
"+" isn't some singular operator. They are different operators for different types using the same character. You'd have to memorize a table of all JS types and what "+" does for each, which is silly considering that the only place it should really be used in modern JS is arithmetic and the occasional string concatenation.
afaik these two places ( arithmetic and string concatenation ) are the only ones where + operation is defined. JS picks one of these two operations and casts the operands accordingly.
Edit: Wait, there is also the unary + which takes only one argument, but it also could be considered arithmetic.
That may be relevant if you are working on a javascript engine, not if you build webapplications.