I am creating my first OO JS library, and I have a little problem with one part, which is probably very simple ...
I have it:
var storageLocker = function(catalog){
if(catalog){
this.catalog = catalog;
}
}()
I need to do what other libraries do, such as jQuery, where you can select an element (in my case, select the localStorage element) and then connect other functions to it. I had everything that works, but for best practice and to make it more extensible later, I put it in an anonymous function, and now I can’t figure out how to have the syntax:
storageLocker('localStorageItem').save({"item":"an example item saved to localStorageItem"})
but right now, if I do this with this syntax, it returns this error:
Uncaught TypeError: Property 'storageLocker' of object [object DOMWindow] is not a function
Any ideas?
source
share