Created
September 9, 2015 15:54
-
-
Save Kasahs/7bf56a7bbe0f19054435 to your computer and use it in GitHub Desktop.
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
function foo(){ | |
var callback = arguments[0] || function(){return "do nothing"}; | |
var options = arguments[1] || {}; | |
return [callback(), options.a || "no A", options.b || "no B", this]; | |
} | |
// try these out to understand how to use apply and what it means to write functions which might be called in this way | |
foo(null, {a:1, b:2}); | |
foo.apply("apples", [function(){return "do something"}, {a:1, b:2}]); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment