prototype主要用来提供对象所属于类的功能,可以利用prototype来扩展类的功能
例如:
WebFXTreeItem.prototype.getLast = function() {
// codes that return the tree's last node here
}
定义WebFXTreeItem的getLast 函数,在JS中就可以使用WebFXTreeItem.getLast()

解决方案 »

  1.   

    楼上的兄弟已经大致上解释了 prototype,其实它就是对象的原形的引用,用它可以对对象进行一些方法的扩充,比如:
    <script language=Javascript>  //自己动手为string添加Trim
    String.prototype.trim  = function(){return this.replace(/(^\s+)|(\s+$)/g,"");}
    var str = "  meizz    ";
    alert(str.trim());
    </script>
      

  2.   

    prototype还为类提供了继承机制<script type="text/javascript">
    function a(){
    this.name = "a.name";
    this.sex = "male";
    }
    function b(){
    this.age = 27;
    }
    b.prototype = new a();
    var bb = new b();
    alert(bb.name); //结果应为 a.name
    </script>
      

  3.   

    我的blog上有一篇转载的文章. 有兴趣可以去看看:
    http://www.corsak.com
    另外, 有做简单的应用出来, 能分享一下吗?
      

  4.   

    EMCAScript
    中的基本语法
    String.prototype.trim  = function(){return this.replace(/(^\s+)|(\s+$)/g,"");}
    老大给的例子
    就类似添加一种类的方法
      

  5.   

    JScript中的prototype(原型)属性研究
    http://birdshome.cnblogs.com/archive/2005/02/17/105403.html
      

  6.   

    <SCRIPT>
    function array_max( ){
       var i, max = this[0];
       for (i = 1; i < this.length; i++)
       {
       if (max < this[i])
       max = this[i];
       }
       return max;
    }
    Array.prototype.max = array_max;
    var x = new Array(1, 2, 3, 4, 5, 6);
    var y = x.max();
    alert(y);
    </script>
      

  7.   

    http://rchen.cnblogs.com/archive/2005/03/02/111230.html
      

  8.   

    呵呵,去下载一个prototype的JS框架来研究一下不就得了。
    里面封装好了AJAX等方面的应用。