An Object that returns an instance of itself
Background: My latest project cannot use a large library, which saddens me. There are a few things that I would like to have from any library such as the missing functions addClass , hasClass , removeClass , compatible addEventListener , etc. So I created a little object which I'd like some opinions on some other time, but I'm having a little bit of trouble setting it up how I'd like. For convenience of use, I want an object to return a new instance of itself on creation. Given: $ = function() { this.name = "levi"; return this; }; console.log($()); We get DOMWindow instead of $ because of the