A
-a
i'm getting an ajax/json response back which is a hash/object with
exactly one key. they key's value determines the kind of record
returned. i wanted a concise way to grab the *first* key from an
object and this is the best i came up with
Object.prototype.first_property = function(){
var property;
for( property in this){ break; }
return property;
}
( { a : 42, b : 42 } ).first_property(); // => 'a'
is there a simpler method of doing this?
kind regards.
exactly one key. they key's value determines the kind of record
returned. i wanted a concise way to grab the *first* key from an
object and this is the best i came up with
Object.prototype.first_property = function(){
var property;
for( property in this){ break; }
return property;
}
( { a : 42, b : 42 } ).first_property(); // => 'a'
is there a simpler method of doing this?
kind regards.