I am building functions to help with urls:
var ap = { /* lots of things removed */ }
ap.url = function(base) {
this.base = base
this.data = "cb_=" + parseInt(Math.random()*99999999);
}
ap.url.prototype = {
nv: function (n,v) {this.data=this.data+"&"+ n+"="+encodeURIComponent(v)},
get: function () { return this.base + "?" + this.data; }
};
var u = new ap.url("site.com");
u.nv("p1", "123");
u.nv("p2", "456");
alert( u.get() )
And this appears to work ok.
Is it possible to create a prototype for the object itself? Like:
alert( u() )
I would like u() to do the same thing as u.get()