There are many ways to get an array of methods, and here are some examples of ways that you think are easier to understand.
Ideas:
- Create a new empty array to hold the new array after the redo.
- Use the For Loop loop to iterate through the array that needs to be weighed.
- Use the
indexOf()
method to query whether the traversed array appears in the new array, and if it does: continue to iterate through the array, if it does not appear: Use the push
method to add to the new array.
- After the original array loop traversal is complete, a new array is formed that has been removed.
<Script> var arr = [1,3,4,5,6,7, 4,3,2,4, 5,6,7, 3,2]; function removerepeatarr (var newArr = []; for (var i = 0; i < arr.length; i++ {if (Newarr.indexof (arr[i]) = = -1) {Newarr.push (arr[i]);}} document.write (NEWARR); }
Removerepeatarr
</script>
indexOf
:
return value:
- Returns 1 if the retrieved result has no matching value.
- Returns 1 if the retrieved result matches to.
- The return value is negative positive 0, which is no longer explained in detail, and an explanation is also opened.
An array of simple chestnuts to go heavy