Skip to content

Instantly share code, notes, and snippets.

@LulzAugusto
Last active August 29, 2015 14:16
Show Gist options
  • Save LulzAugusto/a7072215afcf739ce1cc to your computer and use it in GitHub Desktop.
Save LulzAugusto/a7072215afcf739ce1cc to your computer and use it in GitHub Desktop.
ES6 presentation
function myFnc() {
if (true) {
let a = 'oi';
console.log(a + ' gdg'); // oi gdg
}
console.log(a); // a is not defined
}
// myFnc();
const num = 1;
//num = 2; // "num" is read-only
const ary = [];
ary.push(1);
console.log(ary); // [1]
class Human {
constructor(name) {
this.name = name;
}
describe() {
return 'Human name is ' + this.name;
}
}
let h = new Human('Luiz');
console.log(h.describe()); // Human name is Luiz
class Developer extends Human {
constructor(name, favoriteLanguage) {
super(name);
this.favoriteLanguage = favoriteLanguage;
}
describe() {
return `${super.describe()} and its favorite language is ${this.favoriteLanguage}`;
}
}
let d = new Developer('Luiz', 'JavaScript'); // Human name is Luiz and its favorite language is JavaScript
console.log(d.describe());
let [a, , b] = [1, 2, 3];
console.log(`${a}, ${b}`); // 1, 3
let { first, last } = { first: 'Jane', last: 'Doe' };
console.log(`${first}, ${last}`); //Jane, Doe
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment