Why does the if statement
not work, typeof
says obj is an object.
var obj = {};
console.log(typeof obj);
if(obj === 'object') { console.log('working');}
Why does the if statement
not work, typeof
says obj is an object.
var obj = {};
console.log(typeof obj);
if(obj === 'object') { console.log('working');}
It should be
if (typeof obj === 'object')
for checking if the type is an object.
var obj = {};
document.write(typeof obj + '<br>');
if (typeof obj === 'object') {
document.write('working');
}