0
我想用indexlist
中列出的索引过滤数组中的某些列。以下功能正在投掷:用Javascript过滤数组中的某些列的最佳方法
'范围的坐标或尺寸无效'。
这是什么方法?
function shortenedCol(arrayofarray, indexlist) {
return arrayofarray.map(function(array) {
return array.filter(function(el, idx) {
return this.indexOf(idx) != -1;
}, this);
}, indexlist);
}
var indexlist = [0,2,3];
var arrayofarray = [['a','b','c','d','e'],['a','b','c','d','e'],['a','b','c','d','e']]
console.log(shortenedCol(arrayofarray,indexlist));
请使用Stack Snippets('[<>]'工具栏按钮)以** runnable ** [mcve]更新您的问题,以显示问题。 –
您的[mcve]将需要包含*样本输入数据*来说明问题。 – Quentin
我只是在我自己的samplesata上运行这个函数,它对我很有用。 – Stephan