Javascript: Variable Type

(Last Updated On: )

If you want to test a variable is a type.

var test_type = Object.prototype.toString.call(variable);
//If it is a string type
test_type.includes("String")
//If it is a numeric type
test_type.includes("Number")