I have a code wtfjs:
var a = [,];
alert(a.indexOf(a[0]));
a.indexOf(a[0])returns -1. Central to this example is the difference between the values uninitializedand undefined:
a contains one non-initialized element.
a[0]return statement undefined.
adoes not contain a value undefined. So a.indexOf(a[0]) === -1 true.
But where can I find an explanation why a[0]return undefined? What internal method calls?
PS undefinedis a primitive javascript type. uninitializedmeans a value that has no javascript type, but there is no such primitive type in javascript.
Pinal source
share