DEV Community

Discussion on: 9 Extremely Powerful JavaScript Hacks

Collapse
vuesomedev profile image
Gábor Soós

Useful examples 👍

The word hacks makes me feel you write about dirty shortcuts, but these are actually absolutely good solutions to every-day problems. I wouldn't call them hacks.

Collapse
mburszley profile image
Maximilian Burszley • Edited

Eh.. I wouldn't use most of them in production code (like shortcutting over using an if statement).

Collapse
vuesomedev profile image
Gábor Soós

Yes, that one makes code less readable

Collapse
danoswalt profile image
Dan Oswalt • Edited

Probably not in a class or function, but it's super useful in template code or jsx when you are in need of a terse expression, such as to say 'if object exists, render object.property'... user && user.name, etc

Thread Thread
mburszley profile image
Maximilian Burszley

Leave terse to compilers unless it makes your expression more clear.

Collapse
razgandeanu profile image
Klaus Author

Thank you.
You do have a fair point.
But any word I thought of (tricks, shortcuts, etc) felt like a synonym for "cutting corners".