Subj : problem on array To : netscape.public.mozilla.jseng From : "lyg" Date : Thu Feb 12 2004 03:07 pm Is there a way in SpiderMonkey to detect when a element of one Array is replaced by other value or one new element is set? in another way, it is supposed that: var option1 = new Option(text1 , value1 ,defaultSelected1, selected1); var option2 = new Option(text2 , value2 ,defaultSelected2, selected2); var options = new Array(3); options[0] = option1; options[1] = option2; options[0] = new Options(new_text, new_value, new_def, new_sel); my problem is : when a new element is set, i have to call my app's func1(). when a element is replaced , i have to call my app's fun2(). so how i can do it? i have no way to hnow when I shall call func1() or func2(). i have a solution which i think badly. it need to add some code into jsinterp.c case JSOP_SETELEM: rval = FETCH_OPND(-1); ELEMENT_OP(-2, CACHED_SET(OBJ_SET_PROPERTY(cx, obj, id, &rval))); sp -= 2; STORE_OPND(-1, rval); /* add by lyg 2004.02.06*/ if ( GetOptionAccessFlag() ) { updateBrowserOptionList(obj, rval, JSVAL_TO_INT(id)); } break; note: updateBrowserOptionList decide call func1 or func2 through the obj and JSVAL_TO_INT(id) params. .