Created
November 2, 2018 13:12
-
-
Save douglaspetrin/22f76ca02dcefa721305a30ee9fe00f5 to your computer and use it in GitHub Desktop.
JS Bin // source https://jsbin.com/xehowoc
This file contains 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
<!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> |
This file contains 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
// 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