SHARE
TWEET

Untitled

a guest Jun 19th, 2019 54 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var draftMap = new Map();
  2. draftMap.set(0, {'id': 0, 'name': 'draftName', 'value': 90.01});
  3.      
  4. var list = [
  5.     {'item': [{'id': 0, 'name': 'other name', 'value': NaN}]},
  6.     {'item': [{'id': 1, 'name': 'another name', 'value': 0}]}
  7. ];
  8.      
  9. list = list.map(function(rowDataList) {
  10.     var data = rowDataList.item.map(function(rowData){
  11.         if (draftMap.get(rowData.id)) {
  12.             var draft = draftMap.get(rowData.id);
  13.             rowData.name = (draft.name ? draft.name : rowData.name);
  14.             if(true){
  15.                 console.log(rowData.value); //output: NaN
  16.                 rowData.value = parseFloat(draft.value ? draft.value : rowData.value);
  17.                 console.log(rowData.value); //output: 90.01
  18.                 console.log(rowData); //output: {id: 0, name: "draftName", value: NaN}
  19.             }
  20.         }
  21.         return rowData;
  22.     });
  23.     rowDataList.item = data;
  24.     return rowDataList;
  25. });
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top