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
Those are completely different things. The second one is a standard javascript function declaration (and can be called with sayHi();
), while the first should be rewritten as
new (function sayHi() { alert('hi'); });
Now you can see it is a (named) function expression, which is directly passed to the new operator. This should not be used, if you really wanted to call it immediately (there are applications) use (function(){…})());
.