B
Ben Katz
Is it possible to have an Array object (or an object derived from
Array) that is 'aware' of other code modifying its contents? I'd like
to have such an "onModify" function process an array everytime the []
operator is used to make a change. I know you can derive from Array,
but you cannot directly override the [] operator. Any way to make
this possible?
// possible definition of 'SpecialArray'
...
function OnModify()
{
// process the list
}
...
// an example of use
var myarray = new SpecialArray("zero", "one", "two", "three");
myarray[1] = "ein"; // this causes the array's OnModify to be
called
Thanks for any ideas.
bk
Array) that is 'aware' of other code modifying its contents? I'd like
to have such an "onModify" function process an array everytime the []
operator is used to make a change. I know you can derive from Array,
but you cannot directly override the [] operator. Any way to make
this possible?
// possible definition of 'SpecialArray'
...
function OnModify()
{
// process the list
}
...
// an example of use
var myarray = new SpecialArray("zero", "one", "two", "three");
myarray[1] = "ein"; // this causes the array's OnModify to be
called
Thanks for any ideas.
bk