How do you check the type of a variable in JavaScript?

Beginner

Answer

typeof variable;           // Returns string representation
Array.isArray(variable);   // Check if array
variable instanceof Constructor; // Check instance type
Object.prototype.toString.call(variable); // Most reliable method