How to filter an array without another array javascript
问题 So far I tried this but it returns unfiltered array: function filterRangeInPlace(array, min, max) { array = array.filter(item => (item >= min && item <= max)); console.log(array); } let arr = [5, 3, 8, 1]; filterRangeInPlace(arr, 1, 4); console.log(arr); 回答1: If it's actually important to do the filtering in-place without creating another array, you have to go sort-of old school and iterate through the array with two indexes, copying values along the way. Every time you hit an element that