Saturday, May 11, 2024
 Popular · Latest · Hot · Upcoming
39
rated 0 times [  41] [ 2]  / answers: 1 / hits: 42616  / 12 Years ago, mon, april 16, 2012, 12:00:00

I have a simple example on python:



programs = {}
if not programs.has_key(( program, time )):
programs[( program, time )] = 0
programs[( program, time )] = programs[( program, time )] + 1


How to use array as key in Javascript ?


More From » javascript

 Answers
7

Will this do the trick for you?



jsfiddle



<script>
var ary = {person1:'valerie', person2:'alex'};
for (key in ary) {
document.write(key, '<br>')
}

document.write(ary['person2'], '<br>')
</script>

[#86216] Saturday, April 14, 2012, 12 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
iliana

Total Points: 246
Total Questions: 109
Total Answers: 82

Location: Palestine
Member since Tue, Jul 20, 2021
3 Years ago
;