简体   繁体   English

如何在Javascript对象的现有对象中插入新对象?

[英]How to insert new object inside existing object of objects in Javascript?

I have an object that contains several objects inside it.我有一个对象,其中包含多个对象。

      items: {
            item1: {
              name: '...',
              description: '...',
            },
...
            item6: {
              name: '...',
              description: '...',
            },
    }

I need to insert item new object in the 2nd position of the main items object.我需要在主要项目对象的第二个位置插入item new对象。 How can this be achieved?如何做到这一点? I am using lodash, underscore.js as well.我也在使用lodash,underscore.js。

I have an object that contains several objects inside it.我有一个对象,其中包含多个对象。

      items: {
            item1: {
              name: '...',
              description: '...',
            },
...
            item6: {
              name: '...',
              description: '...',
            },
    }

I need to insert item new object in the 2nd position of the main items object.我需要在主要项目对象的第二个位置插入item new对象。 How can this be achieved?如何做到这一点? I am using lodash, underscore.js as well.我也在使用lodash,underscore.js。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM