<script type="text/javascript">
    //<![CDATA[
function T()
{
this.i=0;
}//没有读写器 - 变向解决
T.prototype.set=function(n) {
this.i = n;
alert("ok");
}t=new T();
t.set(10);//重写输出方法即可
var _w = document.write;
document.write = function(s) {
_w(s);
alert("out");
}
document.write(t.i);
    //]]>
    </script>

解决方案 »

  1.   

    function T()
    {
       this.i=_i;
    }
    function _i(a,b,c)
    {
       return a+b+c;
    }
    --------------------------------function T()
    {
       this.i=function(a,b,c)
       {
         return a+b+c;
       };
    }
      

  2.   

    firefox 下有__defineGetter__ 和__defineSetter__ 方法
    相当于 c# 的get 和set
    但是ie下却没有,只能写成一个方法。function T(){
        this.i=function{alert('do something')}
    }
    var T1=new T();
    T1.i();
      

  3.   

    不知道楼主要是不是这种效果:
    function Class()
    {
    this.a = 123;
    this.b = 234;
    var me = this;
    this.sum = function ()
    {
    return me.a + me.b;
    }();
    }
    var a = new Class()
    alert(a.sum);
      

  4.   

    其实我想实现的就是c++或者c#那样实现属性的方法,在c++或才c#里,设置属性或者读取属性
    实际上都是一个函数.不知道Js怎么模拟?
      

  5.   

    楼主想的是使用公有成员函数,对私有数据成员进行赋值这种操作吗?
    function T(){
    this.i=null;
    this.j=null;
    this.setI=function(sVal){
        this.i=sVal;
    }
    this.getI=function(){
         return this.i;
    }
    }