I have a code like this
const arrayTable = {
array1 : ['A1', 'A2'],
array2 : ['B1', 'B2'],
array3: ['C1', 'C2'],
I want call this sub variable "array1, array2, ..." and input that data to new variable :
var arrayTitle = 'array1', 'array2', 'array3', ...
var arrayTitle = 'array1', 'array2', 'array3', ...
CodePudding user response:
Use Object.keys
var arrayTitle = Object.keys({
array1: ['A1', 'A2'],
array2: ['B1', 'B2'],
array3: ['C1', 'C2'],
});
console.log(arrayTitle);