Last active
December 22, 2015 06:49
-
-
Save zhanhongtao/6433729 to your computer and use it in GitHub Desktop.
匿名函数
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
// 自执行函数 | |
;(function() { | |
//... | |
})(); | |
// dom 绑定. | |
document.onclick = function () { | |
// .... | |
}; | |
document.addEventListener( 'click', function() { | |
// ... | |
}, false );) | |
document.attachEvent( 'onclick', function() { | |
// ... | |
}); | |
setTimeout(function() { | |
// ... | |
}, wait); | |
setInterval(function() { | |
// ... | |
}, wait); | |
// jQuery.promise | |
$.promise().done(function() {}).fail(function() {}); | |
// 字符串替换 - replace | |
'?path=p2'.replace( /[\?|&]path=([^#&]*)/i, function( r0, r1, index, string ) { | |
// ... | |
}); | |
// sort 排序 | |
[1,2,3,2,1].sort(function( a, b ) { | |
// ... | |
}); | |
// 函数执行返回函数. | |
function bind(func, context) { | |
return function() { | |
return func.apply( context || this, arguments ); | |
}; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment