Skip to content

Instantly share code, notes, and snippets.

@marknorgren
Last active August 29, 2015 14:06
Show Gist options
  • Save marknorgren/0e8e1659a85923e6b878 to your computer and use it in GitHub Desktop.
Save marknorgren/0e8e1659a85923e6b878 to your computer and use it in GitHub Desktop.
FrontendMaststers - JS.Next ES 6 Examples
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]
}
// 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