练习:有一个黄色的小狗,叫大黄,今年已经三岁了,250斤的重量每次走路都很慢,喜欢吃大骨头

    1. <script>
    2. function Dog(color,name,age,weight){
    3. this.color = color;
    4. this.name = name;
    5. this.age = age;
    6. this.weight = weight;
    7. this.walk = function(){
    8. console.log(this.name + "摇摇晃晃的摆动");
    9. }
    10. this.eat = function(){
    11. console.log(this.name+"喜欢吃大骨头,但是咬不动");
    12. }
    13. }
    14. //创建对象
    15. var d = new Dog("黄色","大黄",3,250);
    16. console.log(d);
    17. d.walk();
    18. d.eat();
    19. console.log(d.name);
    20. </script>

    image.png