javascriptで型を確認する方法

var foo = 'foo';

var bar = 1;

var obj = {
 id:1,
 name:'foo'
}

var array = ['foo','bar']

console.log(Object.prototype.toString.call(foo)); //[object String]
console.log(Object.prototype.toString.call(bar)); //[object Number]
console.log(Object.prototype.toString.call(obj)); //[object Object]
console.log(Object.prototype.toString.call(array)); //[object Array]