Skip to content

Instantly share code, notes, and snippets.

@kwarodom
Created October 8, 2020 05:58
Show Gist options
  • Save kwarodom/e6c240d04b58379e9fe7d9134015ced1 to your computer and use it in GitHub Desktop.
Save kwarodom/e6c240d04b58379e9fe7d9134015ced1 to your computer and use it in GitHub Desktop.
JS Bin // source https://jsbin.com/pukiyukera
<!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() {
super(); // need to call this to use superclass method
this.name = 'Max';
}
printMyName(){
console.log(this.name);
}
}
const person = new Person();
person.printMyName();
console.log(person.name)
person.printGender()
</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() {
super(); // need to call this to use superclass method
this.name = 'Max';
}
printMyName(){
console.log(this.name);
}
}
const person = new Person();
person.printMyName();
console.log(person.name)
person.printGender()</script></body>
</html>
class Human {
constructor(){
this.gender = 'male';
}
printGender() {
console.log(this.gender);
}
}
class Person extends Human {
constructor() {
super(); // need to call this to use superclass method
this.name = 'Max';
}
printMyName(){
console.log(this.name);
}
}
const person = new Person();
person.printMyName();
console.log(person.name)
person.printGender()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment