一、ES5的循環更新
forEach indexOf map filter reduce some every
var fgoods = [1,2,3,4,5,6,7,8];
for (var i = 0; i < arr.length ; i++){
console.log(arr[i]);
}
語義化更清晰
arr.forEach (function(good){
console.log(good);
})
對象本質的更新:
增長了不可枚舉對象 for in 循環不到的
增長了readonly 對象
console.log(object.prototype);
var obj = {a : 10};
var obj2 = Object.create(obj);//建立原型鏈
console.log(obj,obj2);
function Foo(){} //父級
functioin Ba(){} //子級
function Baz(){} //孫級
Bar.prototype = Object.create(Foo.prototype);
Baz.prototype = Object.create(Bar.prototype);
var baz = new Baz();
原型 .isPrototypeOf(實例)
該實例是否能夠經過原型鏈找到相對應的原型;
console.log(Baz.prototype.isPrototypeOf(baz)); // true
console.log(Bar.prototype.isPrototypeOf(baz)); // true
console.log(Foo.prototype.isPrototypeOf(baz)); // true
console.log(Object.prototype.isPrototypeOf(baz)); // true
console.log(Object.prototype.isPrototypeOf({}));