How to check whether given input is an array or not using JavaScript?

 Solution: 

FlowChart


Example:

 function isArray(input){

if(toString.call(input) === "[object Array]"){

return true;

}else{

return false;

}

test inputs: 1) console.log(isArray('jshub'))

2) console.log(isArray([1, 2,3]))

outputs: 1) true

2) false

Post a Comment

0 Comments

Close Menu