mardi 9 février 2016

for..in loop difference between Ember implementation & other libraries

I am using EmberJS as well as other older libraries (jQuery) in my project

Earlier, without EmberJS, the following code was working fine;

for(var myId in myData){
    updatedData[fieldId] = myData[myId];
}

However, now with Ember, I am facing the issue of enumerating through some additional generated attributes and I have to use following fix;

for(var myId in myData){
    if (!myData.hasOwnProperty(myId)) {  
        continue;  
    }
    updatedData[fieldId] = myData[myId];
}

The problem with the above fix is that it would have to be applied at multiple places.

Is there a better way to fix the issue globally ?

Aucun commentaire:

Enregistrer un commentaire