Javascript中的prototype的一个简单例子
XML/HTML代码
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
- <html xmlns="http://www.w3.org/1999/xhtml">
- <head>
- <title> new document </title>
- <meta name="generator" content="editplus" />
- <meta name="author" content="" />
- <meta name="keywords" content="" />
- <meta name="description" content="" />
- </head>
- <body>
- <script type="text/javascript">
- <!–
- var call = function () {
- //this.a = function (a) { alert(a); };
- this.num = 134;
- }
- call.prototype.a = function (a) { alert(a); };
- var v = new call;
- v.a(v.num);
- //–>
- </script>
- </body>
- </html>