4 ms·
Oof. These days, there are really only two uses cases I see for things like call and apply. First, you're building some fancy clever JavaScript library (as opp
by crazygringo 5y ago
Oof. These days, there are really only two uses cases I see for things like call and apply.
First, you're building some fancy clever JavaScript library (as opposed to regular nuts-and-bolts programming). Then sure, you know what you're doing.
Or second, you've got some really funky array/arguments processing that they either enable, or enable you to do in 1 line instead of 5. But for the love of god, avoid this if you can, and if you absolutely must, then please put it in its own descriptively-named function and/or write a helpful comment explaining it too! Usually, most people reading your code base will have no idea what the line does...