Skip to content

Instantly share code, notes, and snippets.

@douglaspetrin
Created November 2, 2018 13:13
Show Gist options
  • Save douglaspetrin/9b1e39dfe266c11fea7bb63da1dd63ff to your computer and use it in GitHub Desktop.
Save douglaspetrin/9b1e39dfe266c11fea7bb63da1dd63ff to your computer and use it in GitHub Desktop.
JS Bin // source https://jsbin.com/xehowoc
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
</head>
<body>
<script id="jsbin-javascript">
// ES7 Version
class Human {
gender = 'male';
printGender = () => {
console.log(this.gender);
}
}
class Person extends Human {
constructor() { //aqui tá inicializando
super();
this.name = 'Doug';
}
printMyName () {
console.log(this.name);
}
}
const asd = new Person (); {
asd.printMyName();
asd.printGender();
}
// quando usa o extends, estamos usando uma heranca e trazendo o Human para dentro da classe Person
// desse modo, temos q usar o super() **
</script>
<script id="jsbin-source-javascript" type="text/javascript">// ES7 Version
class Human {
gender = 'male';
printGender = () => {
console.log(this.gender);
}
}
class Person extends Human {
constructor() { //aqui tá inicializando
super();
this.name = 'Doug';
}
printMyName () {
console.log(this.name);
}
}
const asd = new Person (); {
asd.printMyName();
asd.printGender();
}
// quando usa o extends, estamos usando uma heranca e trazendo o Human para dentro da classe Person
// desse modo, temos q usar o super() **</script></body>
</html>
// ES7 Version
class Human {
gender = 'male';
printGender = () => {
console.log(this.gender);
}
}
class Person extends Human {
constructor() { //aqui tá inicializando
super();
this.name = 'Doug';
}
printMyName () {
console.log(this.name);
}
}
const asd = new Person (); {
asd.printMyName();
asd.printGender();
}
// quando usa o extends, estamos usando uma heranca e trazendo o Human para dentro da classe Person
// desse modo, temos q usar o super() **
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment