Skip to content

Instantly share code, notes, and snippets.

@leobalter
Created July 15, 2011 05:30
Show Gist options
  • Save leobalter/1084136 to your computer and use it in GitHub Desktop.
Save leobalter/1084136 to your computer and use it in GitHub Desktop.
MyObj creation like jQuery is
(function(window, undefined) {
var MyObj = (function () {
var MyObj = function () {
return new MyObj.fn.init();
};
MyObj.fn = MyObj.prototype = {
init : function () {
return this;
},
count : function () {
for(var i in this) {
if (this.hasOwnProperty(i)) {
console.log("Element "+i+" is "+this[i]);
}
}
}
};
MyObj.fn.init.prototype = MyObj.fn;
MyObj.test = 'yay';
return MyObj;
}());
window.MyObj = MyObj;
}(window));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment