// 输出对象中值大于2的key的数组
// var data = {a: 1, b: 2, c: 3, d: 4};
// Object.keys(data).filter(function(x) { return 1 ;})
// 期待输出:[“c”,”d”]
var data = { a: 1, b: 2, c: 3, d: 4 }
let arr = Object.keys(data).filter(function(x) {
return data[x] > 2
})
console.log(arr)
filter的使用方法
最新推荐文章于 2023-02-08 18:13:21 发布