Skip to content

Instantly share code, notes, and snippets.

@limarc
Last active August 29, 2015 13:55
Show Gist options
  • Select an option

  • Save limarc/8783143 to your computer and use it in GitHub Desktop.

Select an option

Save limarc/8783143 to your computer and use it in GitHub Desktop.
// inherit.js
var inherit = function(parent, child) {
var _ = function() {};
_.prototype = parent.prototype;
child.prototype = new _();
child.prototype.constructor = child;
};
// inherit-es5.js
var inherit = function(parent, child) {
child.prototype = Object.create(parent.prototype);
};
// bind.js
Function.prototype.bind = function(context) {
var fn = this,
args = [].slice.call(arguments, 1);
return function() {
return fn.apply(context, [].concat.apply(args, arguments));
};
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment