This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//惰性单例模式 | |
<a href="javascript:;" id="btn1">1111111</a> | |
<br> | |
<br> | |
<br> | |
<br> | |
<br> | |
<a href="javascript:;" id="btn2">2222222</a> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var timeChunk = function(ary,fn,count){ | |
var obj,t; | |
var len = ary.length; | |
var start = function(){ | |
for(var i = 0 ;i<Math.min(count || 1 , ary.length);i++){ | |
var obj = ary.shift(); | |
fn(obj); | |
} | |
}; | |
return function(){ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//函数节流 | |
var throttle = function (fn,interval){ | |
var __self = fn, | |
timer, | |
firstTime = true; | |
var fun = function(){ | |
var args = arguments, | |
__me = this, | |
outerTime = firstTime; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script type="text/javascript"> | |
//所谓AOP | |
//在执行B前先执行A, | |
//执行完B后再执行C | |
Function.prototype.before = function(beforefn){ | |
var __self = this; | |
console.log(__self); | |
return function(){ | |
beforefn.apply(this,arguments); | |
return __self.apply(this,arguments); |
NewerOlder