vendredi 27 mars 2015

Is there a way to prototype a namespace in a limited scope?

I have a prototyped function that i would like to use it in a limited scope in order to provide it with a jquery plugin.



//Prototype
function StringBuilder(str) {
this.value = str;
}
StringBuilder.prototype.append = function (str) {
this.value = this.value + str;
return this;
};

//jQuery plugin with Revealing module pattern
jQuery.Rut = (function () {
//i would like to be able to use StringBuilder only in this scope
helloWorld = new StringBuilder('Hello');
helloWorld.append(' World');
})(window);


Is that possible?


Thanks


Aucun commentaire:

Enregistrer un commentaire