some and every are the two quantifiers. every loops from index 0 and returns false at the first element whose callback result is falsy (ToBoolean); if it reaches the end, it returns true. some mirrors it: true at the first truthy result, false otherwise. The spec notes call them the "for all" and "exists" quantifiers.
So the empty-array result isn't a special case. With length 0 the loop never runs and each method returns its default: every → true (no counterexample), some → false (no witness). This is vacuous truth, and it keeps !arr.some(p) equal to arr.every(x => !p(x)) for every array, empty included.
Three details:
- Short-circuit. They stop at the deciding element, unlike
filter(...).length. - Holes are skipped. Each index is checked with
HasPropertyfirst, so missing elements are never passed to the callback. - The range is fixed up front.
lengthis read once; elements pushed during the loop aren't visited.
fill(value, start, end) assigns the same value to every index in the range, then returns the array it mutated. With a primitive that's harmless. With an object, every slot holds a reference to one object, so new Array(3).fill([]) is three views of one array. Create a fresh object per slot with Array.from({ length: 3 }, () => []). fill doesn't check HasProperty, so unlike some/every, it fills holes.
copyWithin(target, start, end) copies the elements in [start, end) to positions starting at target, inside the same array. It never grows the array: copying stops at length. When the ranges overlap and the target is after the source, the spec copies backwards, like C's memmove, so the source isn't overwritten before it's read.
All of them read negative indices relative to length and clamp out-of-range ones (ToClampedIndex), and all are generic: they work on any array-like object.