从对象数组中删除键值

时间:2019-09-19 12:40:54

标签: javascript arrays object

假设我有很多这样的对象:

arr = [{time: 1, value: 2, word: 'fdfd'}, {time: 2, value: 3, word: 'dsadsadsa'}]

如何从每个对象中删除时间和单词属性?我的输出应该是这样:

arr = [{value: 2}, {value: 3}]

1 个答案:

答案 0 :(得分:0)

您可以尝试使用Array.prototype.map()Destructuring assignment

public static <T> void reverse(List<T> list) {
    if (list.size() > 0) {
        T t;
        t = list.get(0);
        list.remove(0);
        reverse(list);
        list.add(t);
    }
}