Handling create, update, and destroy for sync I'm pretty sure there's a way to make this "3 times" duplicated code into only one. Any idea how to do this?

if (typeof sync.create!='undefined') {
    for (var i = 0; i &lt;sync.create.length; i++) {
        sync.create[i].modified.id_partenaire=false;
    };  
}   
if (typeof sync.update!='undefined') {
    for (var i = 0; i &lt;sync.update.length; i++) {
        sync.update[i].modified.id_partenaire=false;
    };  
}   
if (typeof sync.destroy!='undefined') {
    for (var i = 0; i &lt;sync.destroy.length; i++) {
        sync.destroy[i].modified.id_partenaire=false;
    };  
}
If this should be executed on all properties of sync in general, i'd go with a for..in loop. 

for(var prop in sync){
  if(sync.hasOwnProperty(prop) &amp;&amp; typeof sync[prop] !== 'undefined'){
    var i=0, l = sync[prop].length;
    for (i; i &lt; l; i+=1) {
        sync[prop][i].modified.id_partenaire=false;
    };
  }
}


Otherwise, if there are more properties and this should only be applied to these 3, Esailija's answer works better.