Javascript Array inside Array - how can I call the child array name?

前端 未结 8 980
不思量自难忘°
不思量自难忘° 2020-12-24 13:42

Here is the example of what I am doing:

   var size = new Array("S", "M", "L", "XL", "XXL");
   var color =          


        
8条回答
  •  梦谈多话
    2020-12-24 14:20

    In that case you don't want to insert size and color inside an array, but into an object

    var options = { 
        'size': size,
        'color': color
      };
    

    Afterwards you can access the sets of keys by

    var keys = Object.keys( options );
    

提交回复
热议问题