Skip to content

Instantly share code, notes, and snippets.

@cheng470
Last active August 29, 2015 14:07
Show Gist options
  • Save cheng470/735971081daf220d01b7 to your computer and use it in GitHub Desktop.
Save cheng470/735971081daf220d01b7 to your computer and use it in GitHub Desktop.
写一个run函数,它接受一个函数作为第一个参数,然后个余下的参数都传递给被调用的函数。
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