Created
February 18, 2016 20:27
-
-
Save stevecass/8408fac1458f75e7c42b to your computer and use it in GitHub Desktop.
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
// 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