I am trying to build up an array of handlers for a 3rd party control. One of the required objects inside is a callback handler. The problem is the allProvider(item) is called, the "theValue" variable no longer points to the same location - it always is set to the last value it was assigned to. What I'd really like to do is evaluate the "theValue.name" immediately when building the array instead of later. I'm open to about any solution at this point. Thanks
var handlers = [];
for(var i=0;i<myArray.length;i++){
var theValue = myArray[i];
handlers.push({
name: myArray.name,
allProvider: function(item){
return "All "+ theValue.name; //This always == myArray[myArray.length - 1]
}
});
}