对象

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script>

        function Car(name,speed){
            this,name=name;
            this.speed=speed;
        }

Car.prototype.showName=function(){


                console.log(this.name)
            }
       


        var car=new  Car("奔驰",300);
        var car2=new Car("宝马",280);

        console.dir(car);
        console.dir(car2);
        //car2.showname();
    </script>
</head>
<body>
   
</body>
</html>
posted @ 2021-11-17 17:28  张慧琳666666  阅读(20)  评论(0)    收藏  举报