直接上代碼了
//Utils function indexOf2dArray(array2d, itemtofind) {
row = array2d.findIndex(x => x.includes(itemtofind))
if (row === false) {
return false
}
col = array2d[row].indexOf(itemtofind)
return [row, col];
}
從二維數(shù)組中查找元素的位置
成功返回行和列的位置,失敗返回false
這個需要es6標(biāo)準(zhǔn)以上
--------------------
原文地址:https://rpa.pbottle.com/a-13963.html