我有一个数组,
data =[{"date":"12/1/12","value":21},
{"date":"12/2/12","value":34},
{"date":"12/1/12","value":36},
{"date":"12/1/12","value":32},
{"date":"12/2/12","value":1},
{"date":"12/2/12","value":4},
{"date":"12/2/12","value":3},]
我需要创建另一个数组,例如从数组中检索值,
data1=[{"date":"12/1/12","value":21},
{"date":"12/1/12","value":36},
{"date":"12/1/12","value":32}]
data2 =[{"date":"12/2/12","value":3},
{"date":"12/2/12","value":4},
{"date":"12/2/12","value":1},
{"date":"12/2/12","value":34}]
答案 0 :(得分:-1)
const data1 = data.filter(datum => datum.date === ‘12/1/12’)
const data2 = data.filter(datum => datum.date === ‘12/2/12’)