---
title: "ES6 One Liners to Show Off"
description: "Collection of impressive ES6 one-liners for destructuring, spread, Sets, and more. Practical notes and code examples on ES6."
url: "https://h3manth.com/scribe/es6-one-liners-to-show-off/"
canonical_url: "https://h3manth.com/scribe/es6-one-liners-to-show-off/"
markdown_url: "https://h3manth.com/scribe/blog/es6-one-liners-to-show-off.md"
publishDate: "2014-02-11T00:00:00.000Z"
author: "Hemanth HM"
category: "javascript"
tags: ["javascript","es6"]
word_count: 113
reading_time_minutes: 1
x_markdown_tokens: 265
content_signal: "ai-train=yes, search=yes, ai-input=yes"
---

# ES6 One Liners to Show Off

> Collection of impressive ES6 one-liners for destructuring, spread, Sets, and more. Practical notes and code examples on ES6.

Here is a collection of ES6 one liners to show off!

## NodeList to Array

```javascript
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! ;)
