var str = 'str';
console.log(typeof str); // string
console.log(str.constructor); // String
function User(){}
var u = new User();
console.log(typeof u); // object
console.log(u.constructor); // User
Variable | typeof Variable | Variable.constructor |
---|---|---|
{an:"object"} |
object | Object |
["an","array"] |
object | Array |
function(){} |
function | Function |
"a string" |
string | String |
33 |
number | Number |
true |
boolean | Boolean |
new User() |
object | User |