![]() |
#2
林月儿2018-06-23 17:56
|
alert(myCar.run());之后又弹出一个undefined的框??????????????

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
</head>
<body>
<script>
function Car(color,size)
{
this.color=color;
this.size=size;
this.run=run;
this.voice=voice;
}
function run()
{
alert("I can run!");
}
function voice()
{
alert("I can voice!");
}
var myCar = new Car("red","middle");
alert(myCar.color);
alert(myCar.run());
alert(myCar.voice());
</script>
</body>
</html>
<html>
<head>
<meta charset="utf-8">
</head>
<body>
<script>
function Car(color,size)
{
this.color=color;
this.size=size;
this.run=run;
this.voice=voice;
}
function run()
{
alert("I can run!");
}
function voice()
{
alert("I can voice!");
}
var myCar = new Car("red","middle");
alert(myCar.color);
alert(myCar.run());
alert(myCar.voice());
</script>
</body>
</html>