JSFiddle - React, Tailwind, and code Playground
data types & undefined
by Christopher O
JavaScript
console.clear();
const array = [{}, [], null, undefined, "", 3, true, false];
/* array.forEach(element => console.log(element)); */
for (var i = array.length - 1; i >= 0; i--) {
let x;
if (array[i]){
x = 'y';
}else{
x = 'n';
}
console.log( i+": "+(typeof array[i])+' / '+x );
if(typeof array[i] != 'undefined'){
console.log("\t1111 Has value");
}
/* if(typeof array[i] != undefined){
console.log("\t2222 Has value");
}
if(typeof array[i] !== undefined){
console.log("\t3333 Has value");
} */
if(typeof array[i] !== 'undefined'){
console.log("\t4444 Has value");
}
}
let y = {};
if(typeof y != 'undefined'){
console.log("y Has value 1");
}
if(typeof y.yy != 'undefined'){
console.log("y Has value 2");
}
if(typeof z != 'undefined'){
console.log("z Has value 1");
}
if(typeof z != 'undefined'){
console.log("z Has value 2");
}
/* if(typeof z.zz != 'undefined'){
console.log("z Has value 3");
} */