Javascript: Check if a variable is an Array

This article shows how you can check if a Javascript variable is of an Array type. There are different ways to check if a variable is an Array in Javascript. 1) First way // define an array var myArray = [11, 'John']; console.log(Object.prototype.toString.call(myArray)); // [object Array] // check if the variable is an array if … Read more

Javascript: Check if a variable is an Object

This article shows how you can check if a Javascript variable is of an Object type. There are different ways to check if a variable is an Object in Javascript. 1) First way // define an object var myObject = {id: 11, name: John} console.log(Object.prototype.toString.call(myObject)); // [object Object] // check if the variable is an … Read more