Skip to content

Instantly share code, notes, and snippets.

@phadej
Created February 26, 2013 13:53
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 phadej/5038550 to your computer and use it in GitHub Desktop.
Save phadej/5038550 to your computer and use it in GitHub Desktop.
var C = function(opts) {
opts = opts || {};
function foo() {
return opts.foo;
}
return {
foo: foo,
};
}
var c = C({foo: "bar"});
c.foo();
var C = (function() {
function C(opts) {
this.opts = opts || {};
}
C.prototype.foo = function() {
return this.opts.foo;
};
return C;
}());
var c = new C({foo: "bar"});
c.foo();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment