1

Possible Duplicate:
Access the first property of an object

I have a hash h decoded from JSON, and it contains only one entry. I don't care (and I don't need to know) about the key for this entry, but just want to get its corresponding value.

What is the fastest method?

Community
  • 1
  • 1
ChrisG
  • 149
  • 2
  • 6

1 Answers1

2

It would be much, much nicer if you knew what the key was, but if not, this should work

var value;
for (var key in h){
    value = h[key];
    break;
}
Adam Rackis
  • 82,527
  • 56
  • 270
  • 393