Question: Write a JavaScript function to check if an input is an array?
Answer:
var arrayCheck = function(input) { if (toString.call(input) === "[object Array]"){ return true; } return false; }; console.log(arrayCheck('rustcodeweb.com')); console.log(arrayCheck([404, 301, 201, 122, 40, 20]));
Output:
false true
We try to provide you the best content, if there is any mistake in this article or there is any mistake in code, then let us know.
Comments
Post a Comment