Here is a function:
function ShowHelloWorld(){
this.x=4;
var y=5;
return 6;
}
Statement 1. var res1 = ShowHelloWorld;
1.1 So, res1 is a copy of ShowHelloWorld function.
1.2 res1() gets 6.
1.3 There is no way to reach values 4 and 5 from res1.
Statement 2. var res2 = ShowHelloWorld();
2.1 res2 gets 6 as a result of a function.
2.2 There is no way to reach values 4 and 5 from res2.
Statement 3. var res3 = new ShowHelloWorld();
3.1 Here res3 is an instance of the function ShowHelloWorld().
3.2 res3.x can be reached. //res3.x==4
3.3 There is no way to reach values 5 and 6 from res3.
Statement 4. var res4 = new ShowHelloWorld; // with no ()
4.1 Seems like res4 is the same res3. Why? (I see it is the same when I test it in the browser console).
4.2 What's the sense of this line (it makes sense if it has no errors, right?)
Please answer my questions or correct my statements in case if they are incorrect or could be even better.
Thank you.