Skip to content

Instantly share code, notes, and snippets.

@hrkd
Last active December 16, 2015 03:29
Show Gist options
  • Save hrkd/5369785 to your computer and use it in GitHub Desktop.
Save hrkd/5369785 to your computer and use it in GitHub Desktop.
applyのthisとの関係を復習。
var fncObj = {
val : 0,
method : function(){
console.log(this.val);
}
}
var obj = {
val:1
}
var obj2 = {
val:2
}
fncObj.method.apply(obj);
fncObj.method.apply(obj2);
fncObj.method();
// 1
// 2
// 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment