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
class MI{ | |
#secretcode=123; | |
getAccess(value){ | |
if(value===this.#secretcode)return 'granted access.'; | |
else return 'access denied.' | |
} | |
} |
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
class Home{ | |
sleep(){ console.log(`${this.name} is sleeping.`) } | |
resting(){console.log(`${this.name} is resting`)} | |
static atHome(){console.log('I am at Home.')} | |
} |
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
class Life{ | |
constructor(medium){ | |
this.medium=medium; | |
} | |
eat(){return `get food from ${this.medium}`}; | |
} | |
class Human extends Life{ | |
constructor(identity,medium){ |
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
function Life(medium){ | |
this.medium=medium; | |
} | |
Life.prototype.eat=function(){return `get food from ${this.medium}`}; | |
function Human(identity,medium){ | |
Object.setPrototypeOf(Human,Life); | |
Life.call(this,medium); | |
this.identity=identity; |
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
const one={ | |
who(){return 'I am the one'} | |
} | |
const two={ | |
getRoots(){ | |
return super.who(); | |
} |
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
class Person{ | |
constructor(name){ | |
this.name=name; | |
}; | |
run(){ return `${this.name} is running.`}; | |
sleep(){return `${this.name} is sleeping.`}; |
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
/** Constructor Functions **/ | |
function Person(name){ | |
this.name=name; | |
} | |
Person.isNamed=function(instance){return !!instance.name} | |
var you=new Person(); /** @returns | |
Person { name: undefined | |
__proto__: constructor: ƒ Person{ | |
isNamed: ƒ (instance) |
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
const Person=function(name){ | |
this.name=name; | |
} | |
Person.prototype.run=function (){ return `${this.name} is running.`}; | |
Person.prototype.sleep=function (){return `${this.name} is sleeping.`}; | |
let woman=new Person('She'); | |
let man=new Person('He'); |
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
const person={ | |
run(){ return `${this.name} is running.`}, | |
sleep(){return `${this.name} is sleeping.`} | |
} | |
let woman=Object.assign( Object.create(person) , {name:'She'} ); /* @returns { | |
name: "She" |
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
(function(){}).prototype | |
@returns { | |
constructor: ƒ () //function on which prototype property was accessed. | |
__proto__: Object | |
} |