-5

I want to create a new object dynamically and insert into the inside of columns object

dynamicCreate = [
    {
        columns: {
            title: {
                title: "Title"
            }
        }
    }
]

Create dynamically like

name: {
    title: "Name"
},

and insert next of

title: {
    title: "Title"
},
fiza khan
  • 1,280
  • 13
  • 24

2 Answers2

1

You can try using the dot notation

var obj={};
obj.title={};
obj.title.title="name";
console.log(obj)
ellipsis
  • 12,049
  • 2
  • 17
  • 33
1

Javascript is a dynamic language. so you can assign any props dynamically to the object.

var obj={
  name:'foo'
};
obj.extraInfo={
  bar:'baz'
}

console.log(obj);
behzad besharati
  • 5,873
  • 3
  • 18
  • 22