开发者

Array Holding an another Object

开发者 https://www.devze.com 2023-03-09 19:12 出处:网络
options: [\'Unknown\', \'AL\', \'AK\', \'AZ\', \'AR\', \'CA\', \'CO\', \'CT\', \'DE\'] This is my Options Array and there are 47 states in all. i don\'t 开发者_StackOverflow中文版want to add it like
options: ['Unknown', 'AL', 'AK', 'AZ', 'AR', 'CA', 'CO', 'CT', 'DE']

This is my Options Array and there are 47 states in all. i don't 开发者_StackOverflow中文版want to add it like this. Instead can i add something like this

options: [StateValue] Which would read all the values from the Object.

var StateValue = {
    Unknown: 0,
    AL: 1,
    AK: 2,
    AZ: 3,
    AR: 4,
    CA: 5,
    CO: 6,
    CT: 7,
    DE: 8,
    FL: 9
};


You can loop through an object like so

var StateValue = {
    Unknown: 0,
    AL: 1,
    AK: 2,
    AZ: 3,
    AR: 4,
    CA: 5,
    CO: 6,
    CT: 7,
    DE: 8,
    FL: 9
};

for(var i in StateValue)
    console.log(i + " :: " + StateValue[i]);

so you could populate your UI in that way

0

精彩评论

暂无评论...
验证码 换一张
取 消