If I created an object that has an array as an attribute, would it be possible to write a method in that object that would make it so that, after an instance is created, that hard-coded commands now acted differently?
For instance, if I defined a constructor:
function Bunny(){
this.arr = [1,2,3];
this.doSomething = function(){
// do something here
}
}
and then created a new instance:
fluffy = new Bunny();
Would it be possible to write something in "this.doSomething" so that when I perform a predefined command, like:
fluffy.arr[0]=7;
that the resulting action (either in addition to or instead of changing the 0th entry of the array from 1 to 7) is that, say, an alert pops up that says, "Happy Easter!"?