首页 > 代码库 > javascript二维数组的删除

javascript二维数组的删除

做百度任务的时候学到一招

例子:

var aqiData = http://www.mamicode.com/[
["北京", 90],
["上海", 50],
["福州", 10],
["广州", 50],
["成都", 90],
["西安", 100]
];

想要删除上海这一项,

var city="上海";

 var newData = http://www.mamicode.com/aqiData.filter(function(item) {
return item[0] != city;
});

aqiData = http://www.mamicode.com/newData;

 

javascript二维数组的删除