Prototype1.5.1源代码解读分析-5
var Abstract = new Object();
代碼解析及其使用方法Abstract(抽象類(lèi))是個(gè)空類(lèi),沒(méi)有任何成員。
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);
??}
});
#javascript/ajax專(zhuān)欄總結(jié)
以上是生活随笔為你收集整理的Prototype1.5.1源代码解读分析-5的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: [转]只让指定的机器连接SQLServe
- 下一篇: 选择预编译模型