<script>
// 1. 创建数组对象
var arr = [1, 2, 3, 4];
// 2. arr就会拥有length属性,push,pop等方法,请问它的属性和方法是它的原型对象给的
console.log(arr.length);
arr.push(5);
console.log(arr);
// 3. 自定义一个构造函数, 给它的构造器和原型对象添加属性或方法
function MadeCat() {
this.name = '猫';
}
MadeCat.prototype.color = '黑色';
MadeCat.prototype.sayName = function() {
console.log(this.name);
}
var cat = new MadeCat();
console.log('cat', cat);
</script>