Skip to content

Instantly share code, notes, and snippets.

@amitabhaghosh197
Created July 14, 2019 18:48
Show Gist options
  • Save amitabhaghosh197/e8adaaaafdd8f2645f133809da4b3101 to your computer and use it in GitHub Desktop.
Save amitabhaghosh197/e8adaaaafdd8f2645f133809da4b3101 to your computer and use it in GitHub Desktop.
JS Bin // source https://jsbin.com/wedemat
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
</head>
<body>
<div id="man"></div>
<script id="jsbin-javascript">
// Extending a class
class Human{
constructor(){
this.gender = "Male";
}
printGender(){
return this.gender;
}
}
class Person extends Human{
constructor(id){
super();
this.id = id;
this.name = "Martin";
this.surname = "Luther";
this.gender = "Male";
}
fullname($id) {
this.id = $id;
let outputDiv = document.getElementById(this.id );
let toAppend = '<p> Name :'+ this.name +'</p>';
toAppend += '<p> Surname :'+ this.surname +'</p>';
toAppend += '<p> Gender :'+ this.gender +'</p>';
return outputDiv.innerHTML = toAppend;
}
}
let person = new Person;
//console.log(person.fullname())
person.fullname('man');
</script>
<script id="jsbin-source-javascript" type="text/javascript">// Extending a class
class Human{
constructor(){
this.gender = "Male";
}
printGender(){
return this.gender;
}
}
class Person extends Human{
constructor(id){
super();
this.id = id;
this.name = "Martin";
this.surname = "Luther";
this.gender = "Male";
}
fullname($id) {
this.id = $id;
let outputDiv = document.getElementById(this.id );
let toAppend = '<p> Name :'+ this.name +'</p>';
toAppend += '<p> Surname :'+ this.surname +'</p>';
toAppend += '<p> Gender :'+ this.gender +'</p>';
return outputDiv.innerHTML = toAppend;
}
}
let person = new Person;
//console.log(person.fullname())
person.fullname('man');</script></body>
</html>
// Extending a class
class Human{
constructor(){
this.gender = "Male";
}
printGender(){
return this.gender;
}
}
class Person extends Human{
constructor(id){
super();
this.id = id;
this.name = "Martin";
this.surname = "Luther";
this.gender = "Male";
}
fullname($id) {
this.id = $id;
let outputDiv = document.getElementById(this.id );
let toAppend = '<p> Name :'+ this.name +'</p>';
toAppend += '<p> Surname :'+ this.surname +'</p>';
toAppend += '<p> Gender :'+ this.gender +'</p>';
return outputDiv.innerHTML = toAppend;
}
}
let person = new Person;
//console.log(person.fullname())
person.fullname('man');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment