javascript - How can I change collection structure by underscore? -


My current collection is given below:

  [[Tom: truth, age: 23}, {jack: truth: age: 22}, {Lucy: wrong, age: 22}] how can i change it with underscore?  
  [{name: 'tom', isMale: true, age: 23}, {name: 'jack', isMale: true, age: 22}, {name: 'lucy' IsMake: true, age: 22}]    

You can copy the internal objects (Swiss Army Knife Iterator), while rearranging the name and isMale values ​​something like this:

  _ (A) .map (function (o) {return _ (o). Reduce (function (memo, v, k) {if (k === 'age') {# through copy 'age' Memo [k] = V} and {# the rest is named: boolean so bust different meme Name = k; memo.is mail = v;} return memo;}, {});});   

Demo:

Comments

Popular posts from this blog

Java - Error: no suitable method found for add(int, java.lang.String) -

java - JPA TypedQuery: Parameter value element did not match expected type -

c++ - static template member variable has internal linkage but is not defined -