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