简体   繁体   中英

How do I extract members of a javascript array into individual variables available to the program?

My Ajax call returns a json_encode d array object that I grab using a function from success: like this:

var poiReturn = $.parseJSON(response);

I extract individual array entries like this:

var POIMarkerList    = poiReturn[2];

But POIMarkerList looks like below and there are others at [0], [1], etc.:

var EOCList = L.layerGroup([W0KCN4, W0KCN3, W0KCN15, NARESEOC]);var FireList = L.layerGroup([RVRSDEFD, KCMOFS1, KCMOFS3, KCMOFS4, KCMOFS5, KCMOFS6, KCMOFS7, KCMOFS8, KCMOFS10, KCMOFS16, KCMOFS17, KCMOFS18])]);

As you can see this example has two var definitions ( EOCList & FireList ). How do I get javascript to create individual variables to make them available to the javascript program as if I had defined them like this?

var EOCList = L.layerGroup([W0KCN4, W0KCN3, W0KCN15, NARESEOC]);
var FireList = L.layerGroup([RVRSDEFD, KCMOFS1, KCMOFS3, KCMOFS4, KCMOFS5, KCMOFS6, KCMOFS7, KCMOFS8, KCMOFS10, KCMOFS16, KCMOFS17, KCMOFS18]);

I've changed directions on this project, and will try it another way.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM