conan conan - 1 year ago 72
jQuery Question

Trying to create an array based on this situation, jquery or javascript

I am trying to create a multidimensional array. something like following code, 44 and 45 is the key. When var pro is 44, I want to get 'onset, frequency' and then split them by .split(','). how should I write this array. Appreciate.

var pro = 44;
var global = [
44 : ["onset",'frequency'],
45 : ["onset"]

Answer Source

First of you have to convert your global array in object like below. And then you can get value for the keys.


please refer below snippet for more understanding.

var pro = 44;
var global = {"44":["onset","frequency"],"45":["onset"]};

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download