JSFiddle - React, Tailwind, and code Playground
by anish_nair
JavaScript
var obj = {first: 'Stack', last: 'Overflow'};
// var obj = ['Stack', 'overflow']; //You can uncomment this line and comment the above to check..
if(Object.prototype.toString.call(obj) !== '[object Array]') {
//your code..
var str = '';
for(var k in obj) {
str = str + obj[k] + ' ';
}
console.log('I love ', str);
alert('I love ' + str);
} else {
console.log('Could not process. Probably an array');
alert('Could not process. Probably an array');
}
console.log('Length is: ', Object.keys(obj).length);
alert('Length is: ' + Object.keys(obj).length);