添加链接
link管理
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接
相关文章推荐
会开车的匕首  ·  How to Convert ipynb ...·  14 小时前    · 
酷酷的烈马  ·  Convert RSA XML ...·  22 小时前    · 
健身的毛衣  ·  sql server ...·  昨天    · 
逆袭的打火机  ·  C# URL Encode (How It ...·  3 天前    · 
有腹肌的萝卜  ·  The ...·  4 天前    · 
性感的椅子  ·  snd_pcm_set_params - ...·  2 月前    · 
坚强的木耳  ·  <!--spider-title-->·  8 月前    · 
Collectives™ on Stack Overflow

Find centralized, trusted content and collaborate around the technologies you use most.

Learn more about Collectives

Teams

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

Learn more about Teams
var array = [{ prop1: "prop1Data1" }, { prop2: "prop2Data1" }, { "prop3.name": "Tom" }],
    object = Object.assign({}, ...array);
console.log(object);
var array = [{ prop1: "prop1Data1" }, { prop2: "prop2Data1" }, { "prop3.name": "Tom" }],
    object = array.reduce(function (r, o) {
        Object.keys(o).forEach(function (k) {
            r[k] = o[k];
        return r;
    }, {});
console.log(object);

The way that I've done it was like so, since it is within an array.

var original = [{"prop1": "prop1Data1"},{"prop2": "prop2Data1"},{"prop3.name": "Tom"}];
var propStore = {
   prop1 : '',
   prop2 : '',
   prop3 : ''
propStore.prop1 = original[0]["prop1"];
propStore.prop2 = original[0]["prop2"];
propStore.prop3 = original[0]["prop3"];
console.log(propStore);
        

Thanks for contributing an answer to Stack Overflow!

  • Please be sure to answer the question. Provide details and share your research!

But avoid

  • Asking for help, clarification, or responding to other answers.
  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.