Last active
August 29, 2015 14:06
-
-
Save marknorgren/0e8e1659a85923e6b878 to your computer and use it in GitHub Desktop.
FrontendMaststers - JS.Next ES 6 Examples
This file contains hidden or 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
function log(logStatement) { | |
console.log(logStatement); | |
} | |
var nums = [1, 2, 3, 4]; | |
doSomething(nums); | |
function doSomething([first, second, ...others]){ | |
log(first); //logs 1 | |
log(second); //logs 2 | |
log(others); //logs [3, 4] | |
} |
This file contains hidden or 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
// https://google.github.io/traceur-compiler/demo/repl.html | |
// Options: --annotations --array-comprehension --async-functions --block-binding --exponentiation --generator-comprehension --symbols --types | |
function setUser(user) { | |
if(!user) return; | |
localStorage.user = JSON.stringify(user); | |
} | |
function getUser() { | |
return JSON.parse(localStorage.user); | |
} | |
setUser({name: 'Mark', age:32}); | |
console.log(getUser()); | |
doThingsWithUser(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment