let result = { a:data.a, b:data.b,
c:data.d,
e:data.e,
f:data.f,
...
}//do sth.
不知道有没有办法简写?
繁花如伊
浏览 120回答 2
2回答
天涯尽头无女友
使用Lodash的pick()方法:var result = _.pick(data, ["a", "b", "d", "e", "f"]);参考How to get a subset of a javascript object's properties