[jQuery] object.prototype

[jQuery] object.prototype


I have been using the jquery for a long time now.. then I've decided
to at least write a simple Ajax class of my own as a part of learning,
and as I'm waiting for John's new coming book(I read somewhere on the
forum from his site that it will teach you how to write your own
library...) .
I just discovered this and please verify me if im correct... when you
declared a property in the prototype as a subClass/ a sub object, and
if you creates/add its property its actually writing to its prototype.
because as from what I have read on some other book, prototype only
works when you are reading a property, but if you're gonna write a
property it would just assign a new property to this object and not on
its prototype.. I think I didn't explain it very well.. please see the
example...
---
function myObject (options) {
this.init(options);
}
myObject.prototype = {
init : function (options) {
options = options || {};
this.options.url = options.url;
}
}
// now two instances
var Myvar1= new myObject({url: 'mysite.php'});
var Myvar2 = new myObject({url: 'Newlysite.php'});
alert(Myvar2.options.url);
alert(Myvar2.options.url);
// and the problem is it will going to alert the same url which is
Newlysite.php.
---
so in order to fix this
init : function (options) {
options = options || {};
this.options ={}; // declare the options property here...
this.options.url = options.url;
}