javascript - Know when a property has been set to an object using array notation -
i have object used hash table store key value pairs in javascript:
storage["key"] = "value".
i've found can use definesetter have setters each key, however, need know key names beforehand. there way of doing whenever value set way?
so example, when doing:
storage["key"] = "value";
i want handled custom method like:
custommethod : function(akey, avalue) { //do these 2 params // inform else this. }
thoughts/suggestions?
no, there isn't way catch property assignments. firefox 4 introduced experimental javascript proxy api allow (have proxy forward calls inner object trigger additional action when properties set) overkill here - if api stable , implemented in other browsers.
Comments
Post a Comment