Created
March 23, 2018 18:23
-
-
Save IdahoEv/13796f2a2d6dad8fcf64dc87e617b324 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
// a function is just a function. By default it has no 'this' and returns nothing | |
function myFunction() { | |
this.value = 5; | |
} | |
// if I call it, I get nothing back | |
var obj1 = myFunction(); // obj1 is undefined | |
// if I call it with 'new', a new empty object is assigned to 'this' and returned to me afterwards | |
var obj2 = new myFunction(); // obj2 is { value: 5 } | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment