[removed] Push into an Array inside an Object?

2019-03-18 04:08发布

问题:

Questions:

  1. How can I push an Array into another Array located inside an Object?

Example Coding:

var myObj = {

    arrayOne: [],

    arrayTwo: []

};

var arrayLetters = ['A', 'B'];

/************************************ 

obj[arrayOne].push(arrayLetters); 

RESULT

    { 

    arrayOne: [['A', 'B']], 

    arrayTwo: [] 

    };

************************************/

Comments:

Essentially, I would like to have an key index for my various arrays.

回答1:

obj.arrayOne.push(arrayLetters);

or

obj['arrayOne'].push(arrayLetters);