check type variable js code example
Example 1: javascript how to know type of variable
var foo = "Hello";
console.log(typeof foo); // string
Example 2: check type string javascript
if (typeof myVar === 'string' || myVar instanceof String)
// it's a string
else
// it's something else