array[index] == 'undefined' compares the value of the array index to the string “undefined”.
You’re probably looking for typeof array[index] == 'undefined', which compares the type.
array[index] == 'undefined' compares the value of the array index to the string “undefined”.
You’re probably looking for typeof array[index] == 'undefined', which compares the type.