Skip to content

Instantly share code, notes, and snippets.

@douglaspetrin
Created November 2, 2018 12:48
Show Gist options
  • Save douglaspetrin/47953d3d20244fc5a3e1ef81f776e578 to your computer and use it in GitHub Desktop.
Save douglaspetrin/47953d3d20244fc5a3e1ef81f776e578 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">
class Human {
constructor() {
this.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">class Human {
constructor() {
this.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>
class Human {
constructor() {
this.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