undefined 是什么原理
运行挺正常的,但是最后在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>