let a = Array(3);
a[0] = 1;
a[1] = undefined;
function test(arr) {
return arr.map(a => !!a);
}
console.log('before', a); // [1, undefined, undefined]
console.log('after', test(a)); // [true, false, undefined]
How can I check if array element is initialized as undefined (a[1]) or not initialized (a[2])? a[2] has empty value, but browser converts it to undefined.