从javascript对象获取第一个键 [英] Get first key from javascript object
本文介绍了从javascript对象获取第一个键的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
假设我们有以下javascript对象:
Let's assume we have the following javascript object:
ahash = {"one": [1,2,3], "two": [4,5,6]}
是否有任何函数,它返回给我对象中第一个键的值? (我不知道密钥名称,我只想获得第一个密钥的值)。
Is there any function, which returns me value of the first key in the object? (I don't know key name, I just want to get value of first key).
推荐答案
在Javascript中你可以做以下内容:
In Javascript you can do the following:
Object.keys(ahash)[0];
这篇关于从javascript对象获取第一个键的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文