Skip to content

Instantly share code, notes, and snippets.

@fearphage
Forked from kangax/gist:88365
Created April 12, 2009 12:54
Show Gist options
  • Save fearphage/93985 to your computer and use it in GitHub Desktop.
Save fearphage/93985 to your computer and use it in GitHub Desktop.
function Foo() {
if (this == window) {
var F = function(){ };
F.prototype = Foo.prototype;
var inst = new F();
Foo.apply(inst, arguments);
return inst;
}
else {
this.init.apply(this, arguments);
}
}
Foo.prototype = {
init: function(msg) {
this.bar(msg);
}
,bar: function(msg) {
document.title += ' / ' + msg;
}
};
Foo('pants');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment