zoukankan      html  css  js  c++  java
  • Asp.net Ajax Library 之js的面向对象类型系统

     js的面向对象类型系统使我们能够按照面向对象的规则来定义和使用类:
      <script language="javascript" type="text/javascript">
       //注册命名空间
      Type.registerNamespace("MyCustomNamespace");
      
      //定义构造函数
      MyCustomNamespace.point=function(x,y)
      {
        this._x=x;
        this._y=y;
      }
      
      // 定义属性集合
      MyCustomNamespace.point.prototype=
       {
        get_x:function()
         {
          return this._x;
         }
        get_y:function()
         {
          return this._y;
         }
       toString:function()
         {
           return String.formate("this point:x={0},y={1}",this.get_x(),this.get_y());
         }
       }
       //注册该类
       MyCustomNamespace.point.registerClass("MyCustomNamespace.point");



     </script>
      

  • 相关阅读:
    Markdown学习
    二叉树的最近公共祖先
    javaCompiler简析
    自定义类加载器
    聚合和组合的区别
    拓扑排序
    C++ map和unordered_map
    静态文件加载路径
    文件上传
    jackson
  • 原文地址:https://www.cnblogs.com/goyier/p/934950.html
Copyright © 2011-2022 走看看