moveZeroes rearranges an array so that every 0 sits at the end while the non-zero values keep their original relative order — and it does this in place, mutating the array you were given instead of building a new one. This is the classic LeetCode 283 interview problem, and the point is the in-place technique, not the result: you return the same array reference you were handed.
moveZeroes(nums)
// mutate `nums` in place — pushing the zeros to the end — then RETURN that same array
moveZeroes([0, 1, 0, 3, 12]); // → [1, 3, 12, 0, 0]
moveZeroes([0, 0, 1]); // → [1, 0, 0] leading zeros slide to the end
const a = [4, 0, 5];
moveZeroes(a) === a; // → true the return value IS the same array, now mutated
moveZeroes(a) === a is true. Do not allocate or return a new array.0 collects in one run at the tail, and the array's length never changes.0 — a value counts as a zero only when it is === 0. Falsy-but-not-zero values like false, '', and null are non-zero and stay in place.