zoukankan      html  css  js  c++  java
  • Prototype1.5.1源代码解读分析5

    < DOCTYPE html PUBLIC -WCDTD XHTML StrictEN httpwwwworgTRxhtmlDTDxhtml-strictdtd>
    Abstract源代码

    var Abstract = new Object();

    代码解析及其使用方法

    Abstract(抽象类)是个空类,没有任何成员。

    Object.extend源代码

    Object.extend = function(destination, source) {

      for (var property in source) {

        destination[property] = source[property];

      }

      return destination;

    }

    Object.extend(Object, {

      inspect: function(object) {

        try {

          if (object === undefined) return 'undefined';

          if (object === null) return 'null';

          return object.inspect ? object.inspect() : object.toString();

        } catch (e) {

          if (e instanceof RangeError) return '...';

          throw e;

        }

      },

      toJSON: function(object) {

        var type = typeof object;

        switch(type) {

          case 'undefined':

          case 'function':

          case 'unknown': return;

          case 'boolean': return object.toString();

        }

        if (object === null) return 'null';

        if (object.toJSON) return object.toJSON();

        if (object.ownerDocument === document) return;

        var results = [];

        for (var property in object) {

          var value = Object.toJSON(object[property]);

          if (value !== undefined)

            results.push(property.toJSON() + ': ' + value);

        }

        return '{' + results.join(', ') + '}';

      },

      keys: function(object) {

        var keys = [];

        for (var property in object)

          keys.push(property);

        return keys;

      },

      values: function(object) {

        var values = [];

        for (var property in object)

          values.push(object[property]);

        return values;

      },

      clone: function(object) {

        return Object.extend({}, object);

      }

    });

  • 相关阅读:
    分治法求最大子序列
    6.2 链表 (UVa 11988, 12657)
    6.1 栈和队列 (UVa 210, 514, 442)
    S-Tree (UVa 712) 二叉树
    Equilibrium Mobile (UVa 12166) dfs二叉树
    Patrol Robot (UVa 1600) BFS
    Knight Moves (UVa 439) BFS
    Tree Recovery (UVa 536) 递归遍历二叉树
    Parentheses Balance (Uva 673) 栈
    Self-Assembly (UVa 1572)
  • 原文地址:https://www.cnblogs.com/netcorner/p/2912303.html
Copyright © 2011-2022 走看看