Learn Different ways to check if a variable is array in Javascript. Using Array.isArray() Using toString() method in Object, this method convert the argument to specific type name, If we pass Object.prototype.toString.call(1) returns “[object Number]”Ā , so if we pass array then it results in “[object Array]”Ā . Using instanceof keyword arr instanceof Array; Using toString method …
Continue reading “Check if your variable is an Array in Javascript.”