Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
53
rated 0 times [  59] [ 6]  / answers: 1 / hits: 29541  / 13 Years ago, thu, june 2, 2011, 12:00:00
var StateValue = {
Unknown: 0,
AL: 1,
AK: 2,
AZ: 3,
AR: 4,
CA: 5,
CO: 6,
CT: 7,
DE: 8,
},


Now i need to get the enumValues.



function getKeyValue(stateVal) {
For example 'AK'
I need to get the corresponding value...
}

More From » javascript

 Answers
187

It is simply:



var val = StateValue[stateVal];


You can access object properties with bracket notation.



I suggest to read MDC - Working with Objects.


[#91898] Wednesday, June 1, 2011, 13 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
naya

Total Points: 60
Total Questions: 87
Total Answers: 87

Location: Guam
Member since Fri, Jun 18, 2021
3 Years ago
;