Created
August 17, 2012 17:14
-
-
Save mugyu/3380723 to your computer and use it in GitHub Desktop.
JavaScript の apply() の使い方メモ
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
fnc = function(str){console.log(this.name + ": " + str)}; | |
obj = {name: "HOGE"}; | |
arg = ["hi!"]; | |
fnc.apply(obj, arg); // => HOGE: hi! | |
// fnc(arg) を obj に適用するって意味かなぁ | |
fnc.apply({name: "FOO"}, ["hello!"]); // => FOO: hello! | |
fnc.apply({name: "BAR"}, ["bood by!"]); // => BAR: bood by! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment