Javascript中的prototype的一个简单例子

XML/HTML代码
  1. >  
  2. <html xmlns="http://www.w3.org/1999/xhtml">  
  3.  <head>  
  4.   <title> new document title>  
  5.   <meta name="generator" content="editplus" />  
  6.   <meta name="author" content="" />  
  7.   <meta name="keywords" content="" />  
  8.   <meta name="description" content="" />  
  9.  head>  
  10.   
  11.  <body>  
  12.   <script type="text/javascript">  
  13.   
  14.     var call = function () {  
  15.         //this.a = function (a) { alert(a); };  
  16.         this.num = 134;  
  17.     }  
  18.     call.prototype.a = function (a) { alert(a); };  
  19.     var v = new call;  
  20.     v.a(v.num);  
  21.   //–>  
  22.   script>  
  23.  body>  
  24. html>