js定义一个数组存放number类型然后把数组重复的数字去掉?答:let numArr = [1, 1, 2, 3, 4, 5, 6, 7, 7, 7, 8]let tempObj = {} let result = []numArr.map(i => { if (!tempObj[i]) { tempObj[i] = i result.push(i)} })console.log(result)
用JS代码实现给定一个数组,[1,2,3,4,5,6,7,8,9],分别求它们的立方。_百...答:var arr1 = [1,2,3,4,5,6,7,8,9];var arr = arr1.map(function(item,index,array){ return item*item*item;})返回的新数组arr则是元素立方运算后的新数组