On a function like this one:
Array.sort((a,b) => a - b)
If my array has many items, how does the 'a' and 'b' applies the condition to all of the items ? Because it's the case¹, but it's not the case on a regular function like this one:
function isItMatterWhatsMyName(a, b) {
return a - b
}
console.log(isItMatterWhatsMyName(1,2,3,4))
It would apply only on 1 and 2, the 3 & 4 will be forget by the function.
¹ Does it apply only to the sort()
or is there more functions that apply this logic ?