题解 | #查找元素位置#
查找元素位置
http://www.nowcoder.com/practice/0a9af9cb20c34babb6232126e019c74d
function findAllOccurrences(arr, target) {
return arr.map(function(val,index){
if(val===target){
return index
}
})
}
一般返回新数组的首选map遍历,简单粗暴