Hmm, interesting. Frankly, i have no idea about the constructor thing -- half expected it to throw an error. But I'm still not sure why you're so reluctanct to use the main prototype; this is what it's for. Ultimately, you're looking for a way to use an instance to _get_at_ the main prototype... so why not just do it directly? It's a feature of the language, man.

test.prototype.color = 'purple';

On 6/21/06, Sam <[EMAIL PROTECTED]> wrote:
Also... you said:

** After declaring the Class, I've never had to mess with a class before.

:-) you're still thinking of _javascript_ as a classical OO language, when it's not. Embrace the power of the prototype.

Yes, my problem is getting to the point where this "feels" right. 
 
oMyObject.constructor.prototype.bSwitch = true; // doesn't produce an error, and doesn't change the global value in the class prototype, so what is it changing?
 
<script type="text/_javascript_">
var test = function () {}
test.prototype = {color: 'red'};
var oTest1 = new test();
var oTest2 = new test();
oTest2.__proto__.color = 'blue';
alert('oTest1:color=' + oTest1.color + ' oTest2:color=' + oTest2.color); // blue blue
test.prototype.color = 'green';
alert('oTest1:color=' + oTest1.color + ' oTest2:color=' + oTest2.color); // green green
oTest1.constructor.prototype.color = 'purple';
alert('oTest1:color=' + oTest1.color + ' oTest2:color=' + oTest2.color); // green green -- not what we want
</script>
 


_______________________________________________
Rails-spinoffs mailing list
[email protected]
http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs



_______________________________________________
Rails-spinoffs mailing list
[email protected]
http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs

Reply via email to