Pages

05 September, 2024

Why does emptyArray.every() return true in Javascript?

Why emptyArray.every() returns true? It doesn´t make sense to me because there is no element which you can apply the callBackFunction on?


Example:
let x=[];
x.every(n=>n>10);



I would expect an error...

No comments:

Post a Comment

Thanks