JavaScript Prototype Extension


SUBMITTED BY: YouKnowNothing

DATE: Jan. 3, 2016, 5:20 a.m.

FORMAT: JavaScript

SIZE: 314 Bytes

HITS: 6248

  1. function Food(eatable){
  2. this.eatable = eatable || false;
  3. }
  4. //Bacon extends food
  5. function Bacon(eatable, cancerous){
  6. Food.call(this, eatable);
  7. this.cancerous = cancerous || false;
  8. }
  9. Bacon.prototype = Object.create(Food);
  10. Bacon.prototype.constructor = Bacon;
  11. var baconStrip = new Bacon(true, false);

comments powered by Disqus