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 on the variable
Letβs assume we have a variable a = 10Β , when we call a.constructor.toString() it returns "function Number() { [native code] }βΒ . Similarly if we pass array then instead of number it returns Array.


Learn about unknown things about ** operator here.
If you find this helpful surprise π me here.
Share if you feel happy π π πΒ .
Follow Javascript Jeepπ if you feel worthy.