helpfer-isSimpleObj
by shan10213223
JavaScript
function isSimpleObj (input) {
if (input === undefined || input === null || input === '' || typeof(input) === 'number' || typeof(input) === 'string' || typeof(input) === 'function' || typeof(input) === 'boolean') {
return true;
} else {
return false;
}
}
let simpleArray = [0, "This is a string", function(){}, "", null, undefined];
for (let i=0; i<simpleArray.length; i++) {
console.log(simpleArray[i], isSimpleObj(simpleArray[i]));
}
let complexArray = [[0, "This is a string", function(){}, "", null, undefined], {"num": 0, "string": "This is a string", "emptyString": "", "null": null}];
for (let i=0; i<complexArray.length; i++) {
console.log(complexArray[i], isSimpleObj(complexArray[i]));
}