Created
July 29, 2019 17:10
-
-
Save ppraksa/0305a7e9ffd48b563f992d5b06edee96 to your computer and use it in GitHub Desktop.
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 Device(power) { | |
this.power = power; | |
this.turnPower = function() { this.power = !this.power }; | |
} | |
Device.prototype.sayHello = function() { this.power ? console.log('hello, the power is on') : ''} | |
function Computer(proccessor, memory) { | |
this.proccessor = proccessor; | |
this.memory = memory; | |
Device.call(this,true); | |
} | |
Computer.prototype = Object.create(Device.prototype); | |
Computer.prototype.constructor = Device; | |
var IBM = new Computer('133MHz','16MB of RAM'); | |
IBM.sayHello(); | |
IBM.turnPower(); | |
IBM.sayHello(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment