Created
October 11, 2015 10:16
-
-
Save v3rt1go/90446f9113281d996f7c to your computer and use it in GitHub Desktop.
This file contains 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 form | |
function fnForm() { | |
console.log('function form: ', this); | |
} | |
fnForm(); // function form - this is the global object - (window) | |
// method form | |
var parent = function parent() { | |
var p = {}; | |
p.methodForm = function methodForm() { | |
console.log('method form: ', this); | |
}; | |
this.applyForm = function applyForm() { | |
console.log('apply form: ', this); | |
} | |
return p; | |
} | |
var f = parent(); | |
f.methodForm(); | |
// constructor form | |
var fn = new fnForm(); | |
// apply/call form | |
fnForm.call(parent, 1, 2); | |
fnForm.apply(parent, [1, 2]); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment