发布于 2016-12-23 21:23:45 | 119 次阅读 | 评论: 0 | 来源: 网友投递

这里有新鲜出炉的Javascript教程,程序狗速度看过来!

JavaScript客户端脚本语言

Javascript 是一种由Netscape的LiveScript发展而来的原型化继承的基于对象的动态类型的区分大小写的客户端脚本语言,主要目的是为了解决服务器端语言,比如Perl,遗留的速度问题,为客户提供更流畅的浏览效果。


这个SDelegate用起来可能会比较诡异,比如很多操作都要重新赋值。Dess中,SDelegate主要用于一些特定场合,如DOM事件派发。
 
var SDelegate = function(f, b, c) { 
if (b) { 
this.asFunction_ = function() { 
return f.apply(b, arguments); 
} 
} else { 
this.asFunction_ = function() { 
return f.apply(this, arguments); 
} 
} 
this.method_ = f; 
this.binding_ = b; 
this.continus = c; 
} 
SDelegate.composite = function(d) { 
if (d.continus) { 
var con = d.continus.composited_ = SDelegate.composite(d.continus); 
var method = d.asFunction_; 
return function() { 
con.apply(this, arguments); 
return method.apply(this, arguments); 
} 
} else { 
return d.asFunction_; 
} 
} 
SDelegate.prototype.call = function() { 
if (!this.composited_) this.composited_ = SDelegate.composite(this); 
return this.composited_.apply(arguments[0], Array.prototype.slice.call(arguments, 1)); 
} 
SDelegate.prototype.remove = function() { 
var removeP = function(parent, item, test, data) { 
if (!item) return; 
parent.composited_ = item.composited_ = null; 
if (test(item, data)) { 
parent.continus = item.continus; 
removeP(parent, item.continus, test, data); 
} else { 
removeP(item, item.continus, test, data); 
} 
}; 
return function(test, data) { 
var p = this; 
if (test(this, data)) { 
p = this.continus; 
} 
removeP(p, p.continus, test, data); 
p.composited_ = null; 
return p; 
} 
}(); 
SDelegate.prototype.append = function(f, b) { 
return new SDelegate(f, b, this); 
} 

这个SDelegate用起来可能会比较诡异,比如很多操作都要重新赋值。Dess中,SDelegate主要用于一些特定场合,如DOM事件派发。

最新网友评论  共有(0)条评论 发布评论 返回顶部

Copyright © 2007-2017 PHPERZ.COM All Rights Reserved   冀ICP备14009818号  版权声明  广告服务