Created
July 20, 2016 09:31
-
-
Save MD4/ed622bb2fff29c79deb1608d141d41f1 to your computer and use it in GitHub Desktop.
🆕 What's new in ES7 ?
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
var todo = {a: [1, 2, 3]}; | |
console.log((todo === { ...todo, a: [...todo.a] })); // false | |
console.log((todo.a === { ...todo, a: [...todo.a] }.a)); // false | |
console.log(todo, { ...todo, a: [...todo.a] }) // {"a":[1,2,3]} {"a":[1,2,3]} | |
console.log([1,2,3,4].includes(1)) // true | |
console.log([1,2,3,4].includes(5)) // false | |
console.log(2 ** 8) // 256 | |
let { x, y, ...z } = { x: 1, y: 2, a: 3, b: 4 } | |
console.log(x, y, z) // 1 2 {"a":3,"b":4} | |
let n = { x, y, ...z }; | |
console.log(n) // {"x":1,"y":2,"a":3,"b":4} | |
let lol = message => new Promise( | |
done => setTimeout( | |
() => done(`Meh. ${message}`), | |
1000 | |
) | |
) | |
let lol2 = message => new Promise( | |
(done, err) => setTimeout( | |
() => err('AARGHH'), | |
1000 | |
) | |
) | |
async function main() { | |
console.log('loling...') | |
let res1 = await lol('test1') | |
let res2 | |
try { | |
res2 = await lol2('test2') | |
} catch (err) { | |
console.error('err: %s', err) | |
} | |
console.log(res1, res2) | |
} | |
main() | |
// loling... | |
// err: %s AARGHH | |
// Meh. test1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment