0

So, I have the following mixed array in js:

  var MY_INFO = {
       'NAME' : ['input1', 'inpu2', 'input3']
  };

I need to push values into this format. How can I achieve this?

Thanks.

EDIT:

Realized that my question was not specific enough.

So, I have 4 specific data:

  1. Name
  2. Input1
  3. Input2
  4. Input3

The function is :

function push_my_info(name,input1,input2,input3){
    var MY_INFO = {
       name : [input1, input2, input3]
    };
}

Something like this..

However, bit confused to how to push it properly so there can be multiple "top" objects.

Steve Kim
  • 5,293
  • 16
  • 54
  • 99

1 Answers1

1

var MY_INFO = {
       'NAME' : ['input1', 'inpu2', 'input3']
};

MY_INFO.NAME.push('whatever I want!');

console.log(MY_INFO.NAME);
<script src="https://getfirebug.com/firebug-lite-debug.js"></script>

You can use push:

MY_INFO.NAME.push('whatever I want!');

Matt
  • 5,315
  • 1
  • 30
  • 57