【发布时间】:2017-02-19 00:49:40
【问题描述】:
我知道有很多解决方案可以从对象数组中获取单个值。但我认为必须有一种无需显式函数即可直接访问值的方法。
我在 nodejs 中有一组用户,我将它们发送到前端并通过result.data 获取,但我只想在控制台中打印所有用户的 objectName。
[{"objectName":"cn=anna,ou=user,ou=system",
"sn":["1"],
"cn":["test1"],
"objectClass":["top","inetOrgPerson","person","organizationalPerson"],
"userPassword":["password"],
"uid":["12345"]},
{"objectName":"cn=tim, ou=user,ou=system",
"sn":["2"],
"cn":["test2"],
"objectClass":["top","inetOrgPerson","person","organizationalPerson"],
"userPassword":["password"],
"uid":["125342"]}
]
有解决办法吗?像console.log(result.data.objectName) ..?
【问题讨论】:
-
如果你想访问多个而不是。没有函数就无法完成
标签: angularjs arrays node.js object