Like explore javascript as my first reference to the whole programming but as i'm not the professional can't comprehend a lot of stuff. So it would be so much appreciated if someone can explain what actually happens behind the scene.
In body tag i declared two functions one with "new" and another one without.
- new function sayHi () {alert('hi')}
- function sayHello () {alert('hello')}
So the first function is invoked without usage of (), so i can see "hi" just while document is loading as i understand it correctly. But to see "hello" i should use something like sayHello.call() somewhere in the code.
I guess i understand main purpose of the "new" operator as a creating object instances, furthermore even can assume that there is a slight difference between declare instances of the function object with or without 'new' operator.
But what actually happens so that the document executes the function with 'new' operator while it's definition, and another one just leaves somewhere in the memory?