Skip to content

Instantly share code, notes, and snippets.

@binki
Created May 8, 2015 17:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save binki/0a6b1a3ead735ca2ce8f to your computer and use it in GitHub Desktop.
Save binki/0a6b1a3ead735ca2ce8f to your computer and use it in GitHub Desktop.
no infinite recursion
ohnobinki@ohnopublishing ~ $ js
js> function SuperClass() {}; SuperClass.prototype = {do: function () {print('hi');}};
({do:(function () {print("hi");})})
js> function MyClass(){}; MyClass.prototype = Object.create(SuperClass.prototype); MyClass.prototype._do_base = MyClass.prototype.do; MyClass.prototype.do = function (){ if (this.name === 'something'){/*do something new*/}else{return this._do_base();}};
(function () {if (this.name === "something") {} else {return this._do_base();}})
js> var myInstance = new MyClass();
js> myInstance.do();
hi
js> quit();
ohnobinki@ohnopublishing ~ $
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment