7 hacks with ES6 developer

Tram Ho

Today I will introduce you some hacking in es6. Specifically as follows.

Hack 1: Swap variables

We will use Array Destructuring to swap values ​​like the following example:

Hack 2: Async / Await with Destructuring

Array Destructuring is amazing again. It combines with async / await and promises to create a simple and complex flow

Hack 3: Debugging

We often use debug with console.log and to print out each value. And here it is great with syntax like console.table

Hack 4: One liners

This syntax can be a lot more compact for array operations:

Hack 5: Array concatenation

Normally we concatenate 2 arrays using the concat operator
And try the following instead of using concat

Simple is not it!

Hack: 6 Cloning

For ordinary arrays or objects, we clone them many ways but I found no easy way like this:

Quick and light.

Hack 7: Named parameters

Create functions and call functions more readable with destructuring:

As an example we see the way below it describes more specifically and more explicitly the variables passed to the function instead of the above.

Source: https://medium.com/dailyjs/7-hacks-for-es6-developers-4e24ff425d0b

Chia sẻ bài viết ngay

Nguồn bài viết : Viblo