JavaScript hacks for ES6 hipsters

Tal Bereznitskey
HackerNoon.com
2 min readNov 30, 2017

--

Following the original JavaScript hacks for hipsters, here’s some new goodies. Coding JavaScript in 2018 is actually fun again!

Here’s a photo of non-JavaScripter, non-hacker, non-ES6er, non-hipster on a PacMan background:

Hipster Hack #1 — Swap variables

Using Array Destructuring to swap values

Hipster Hack #2 — Async/Await with Destructuring

Once again, Array Destructuring is great. Combined with async/await and promises to make a complex flow — simple.

Hipster Hack #3 — Debugging

For anyone who likes to debug using console.logs, here’s something awesome (and yes, I heard of console.table):

Hipster Hack #4 — One liners

Syntax can be so much more compact for array operations

Hipster Hack #5 — Array concatenation

The spread operator can be used instead of concat:

Hipster Hack #6 — Cloning

Clone arrays and objects with ease:

Update: As mentioned in the comments — this is a shallow clone.

Hipster Hack #7 — Named parameters

Making function and function calls more readable with destructuring:

Already knew them all?

You’re a true hipster hacker, you can read more tips & tricks for writing better code.

Let’s talk more on twitter. You can also check my startup Torii where we make “SaaS headache” go away.

--

--