Created
September 29, 2018 11:57
-
-
Save akumbhani66/e03a5a04c02e38cfd57853476ab571d9 to your computer and use it in GitHub Desktop.
ES6 tricks to make life easy with javascript.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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