一切皆对象

undefined, number, string, boolean 属于简单的值类型,不是对象。剩下的几种情况——函数、数组、对象、null、new Number(10)都是对象。他们都是引用类型。

**函数**
var fn = function () { };
console.log(fn instanceof Function);//true
console.log(fn instanceof Object);//true

**数组**
let arr = []
console.log(typeof arr)//object
arr.a = 'hello'
arr.sayhello = function(){
    console.log('sayhello')
}
arr.sayhello()//sayhello

**null**
console.log(typeof null)//object

**new Number**
let num = new Number(10)
console.log(num + 1)//11
console.log(typeof num)//object

最好的JS深入教学:深入理解javascript原型和闭包(完结)