Skip to content

Instantly share code, notes, and snippets.

@akumbhani66
Created September 29, 2018 11:57
Show Gist options
  • Save akumbhani66/e03a5a04c02e38cfd57853476ab571d9 to your computer and use it in GitHub Desktop.
Save akumbhani66/e03a5a04c02e38cfd57853476ab571d9 to your computer and use it in GitHub Desktop.
ES6 tricks to make life easy with javascript.
includes.
=========
// old way was using indexOf() functio.
let a = "ABCD"
console.log(a.includes("A")) // true
console.log(a.includes("Z")) // false
Remove unwanted properties from object.
=======================================
// old way was using delete keyword.
let a = { a1: 444, a2: 555, a3: 666}
let {a1, a2 ...b} = a;
console.log(b) // { a3: 666 }
// https://developit.github.io/preact-perf/ => batchmark test for different frontend library and frameworks
Swap values
=============
let a = 1;
let a2 = 2;
console.log(a, a2); // 1 2
[a1, a2] = [a2, a1];
console.log(a, a2); // 2 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment