如何对微信小程序中的js数组进行过滤,其实与javascript语法是一样的
简单数组示例
var a =[1,2,3,4,5,6,7,8,9]var r = a.filter(o=> o.<5)console.log(r)输出结果:[1, 2, 3, 4]
数组对象示例
var aa =[{id:1,name:"张三"},{id:2,name:"李四"},{id:3,name:"王五"}]var bb = aa.filter(o=> o.id<3)console.log(bb)输出结果0: {id: 1, name: "张三"}1: {id: 2, name: "李四"}