var col = Column.prototype;
问题就在这个地方
改成这样
<html>
<head>
<script type= "text/javascript">
function Column(cId,cName,cDesc) {
      var col = Column.prototype;
      this.cId = cId;
      this.cName = cName;
      this.cDesc = cDesc;
      
      col.getCId = function () {
          return this.cId;
      }
      col.getCName = function () {
          return this.cName;
      }
      col.getCDesc = function () {
          return this.cDesc;
      }
  }
  var obj1 = new Column(1,'1','1');
  var obj2 = new Column(2,'2','2');
  alert(obj1.cId);
  </script>
  </head>
  <body>
  </body>
  </html>
就ok了prototype.property是所有对象实例共享的东西,所以会覆盖

解决方案 »

  1.   

    <script type="text/javascript">
    var Class = function (a) {
    Class.prototype.s = function () {
    alert(a);
    };
    };var a = new Class(1);
    var b = new Class(2);
    a.s();
    </script>解决方法1
    <script type="text/javascript">
    var Class = function (a) {
    this.s = function () {
    alert(a);
    };
    };var a = new Class(1);
    var b = new Class(2);
    a.s();
    </script>
    以下省略^^
      

  2.   

    哦,明白了,我开始以为prototype就是为了避免共享的呢!谢谢各位!
      

  3.   

    ^^prototype的修改最好不要写在构造里....