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.
** 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>
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
