Last active
August 29, 2015 14:07
-
-
Save cheng470/735971081daf220d01b7 to your computer and use it in GitHub Desktop.
写一个run函数,它接受一个函数作为第一个参数,然后个余下的参数都传递给被调用的函数。
This file contains hidden or 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
run = (func, arg...) -> func arg... | |
### | |
生成的js代码: | |
var run, | |
__slice = [].slice; | |
run = function() { | |
var arg, func; | |
func = arguments[0], arg = 2 <= arguments.length ? __slice.call(arguments, 1) : []; | |
return func.apply(null, arg); | |
}; | |
### | |
run = (func, args...) -> func.apply this, args | |
run = (func, args...) -> func.call this, args... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment