Here is a collection of ES6 one liners to show off!
NodeList to Array
var headings = [ ...document.querySelectorAll('h1') ];
## Unique Arrays
javascript
[ ...new Set(array) ]
## Destructuring
javascript
var {foo, bar} = {foo: "lorem", bar: "ipsum"};
// foo => lorem and bar => ipsum
## Swap Like a Snake
javascript
[a, b] = [b, a]
## Max in Array
javascript
Math.max(...array);
## Arrow Map
javascript
[{id: 1}, {id: 2}].map(x => x.id)
// [1, 2]
## Is it a Hidden File?
javascript
isHidden = (file) => /^\.|~$/.test(file);
isHidden(".DS_STORE") // true
## Repeat with Me
javascript
(0/0+"").repeat("7") + " BatMan!"
// "NaNNaNNaNNaNNaNNaNNaN BatMan!"
Hope it blew your mind! ;)
#javascript#es6
About Hemanth HM
Hemanth HM is a Sr. Machine Learning Manager at PayPal, Google Developer Expert, TC39 delegate, FOSS advocate, and community leader with a passion for programming, AI, and open-source contributions.