Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

js中如何快速获取json对象的最后一项的值 #90

Open
Seasons123 opened this issue Aug 28, 2018 · 0 comments
Open

js中如何快速获取json对象的最后一项的值 #90

Seasons123 opened this issue Aug 28, 2018 · 0 comments

Comments

@Seasons123
Copy link
Owner

没办法。
Key-Value数据结构是无法保证其顺序的,不管是 for...in 还是其它任何迭代方法,若你真保证数据有效性,还是使用 Array 吧。

一个获取的写法:data[Object.keys(data)[Object.keys(data).length - 1]]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant