Created
July 14, 2019 18:48
-
-
Save amitabhaghosh197/e8adaaaafdd8f2645f133809da4b3101 to your computer and use it in GitHub Desktop.
JS Bin // source https://jsbin.com/wedemat
This file contains hidden or 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> | |
<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> |
This file contains hidden or 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
// 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