Skip to content

Instantly share code, notes, and snippets.

@ppraksa
Created July 29, 2019 17:10
Show Gist options
  • Save ppraksa/0305a7e9ffd48b563f992d5b06edee96 to your computer and use it in GitHub Desktop.
Save ppraksa/0305a7e9ffd48b563f992d5b06edee96 to your computer and use it in GitHub Desktop.
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