js comment filtrer la gamme tableau imutable

// @ts-check
let arr = [5, 3, 8, 1];

function filterRange(arr, a, b) {
  return arr.filter((item) => a <= item && item <= b);
}

let filtered = filterRange(arr, 1, 4);

console.log(filtered); // => [ 3, 1 ]
console.log(arr); // => [ 5, 3, 8, 1 ]
Condemned Corncrake