Skip to content

Instantly share code, notes, and snippets.

@stevecass
Created February 18, 2016 20:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stevecass/8408fac1458f75e7c42b to your computer and use it in GitHub Desktop.
Save stevecass/8408fac1458f75e7c42b to your computer and use it in GitHub Desktop.
// ES 6 basics
setTimeout(() => {
console.log('Hello');
console.log('Goodbye');
}, 200);
// One - liners can omit the { }
// and implicitly return the value of their statement
setTimeout(() => 5, 200)
//One liners can return their last statement
new Promise((resolve, reject)=> {
setTimeout(()=> resolve(5), 2000 );
})
.then((arg) => 10 * arg )
.then((arg) => console.log('second then was passed ' + arg));
//Class syntax makes OOJS easier
class Person {
constructor(name, dob, skills) {
this.name = name;
this.dob = dob;
this.skills = skills || [];
}
concatSkills() {
var result = '';
this.skills.forEach((skill) => {
result += skill + ' ';
console.log('this', this);
});
return result;
}
}
var person = new Person('James', new Date('01-01-1999'), ['running', 'swimming']);
console.log(person.concatSkills());
var bigString = `
I am a big String
on more than one line
I can go on
as long as I want
`;
console.log(bigString);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment