So I got a JSON array like this one:
"robots": [
{
"id": 1,
"name": "foo",
"last_connection": "2017-03-18 14:25:36"
},{
"id": 3,
"name": "bar",
"last_connection": "2017-03-19 17:28:39"
},{
"id": 8,
"name": "foobar",
"last_connection": "2017-04-18 11:22:33"
}
]
有没有一种简单的方法可以从我的所有机器人中获取id数组,而无需在数组上进行for循环?
ids = [1, 3, 8]
Array.map()
会完成这个任务,试一试。 - RomanPerekhrest