The problem of function declaration, function variable and constructor call

the code is as follows

function Foo(){
    getName = function(){
        console.log(1);
    };
    return this;
}
Foo.getName = function() {
    console.log(2);
}
Foo.prototype.getName = function(){
    console.log(3);
}

var getName = function(){
    console.log(4);
};

function getName() {
    console.log(5);
}

Foo.getName(); // 
getName(); // 
Foo().getName(); // 
getName(); // 
new Foo.getName(); // 
new Foo().getName(); //  
new new Foo().getName(); //

what I want to ask now is: can"t new Foo () be written as new Foo without parentheses? why is the result different between question 5 and question 6? and the last question directly does not understand why the result is like this. Thank you for your generous advice

.
May.03,2022

I. As to why No. 5 and No. 6 are different, in this case, there is a difference between whether or not to wear parentheses.

https://codeshelper.com/q/10...

I. Last question

new Foo (). GetName ();
equates to const a = new Foo (); a.getName (); that is Foo.prototype.getName ()

new new Foo (). GetName ();
as const A = new Foo (). GetName; new A ();
then as const A = Foo.prototype.getName; new A ();

in addition, operator precedence


1, question 5 and question 6 have different results.
has different priorities
new Foo.getName (); is similar to new (Foo.getName) ()
new Foo (). GetName (); is similar to (new Foo ()). GetName ()
2, the last question is a better understanding of new ((new Foo ()) .getName) ()

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1e52bb3-44963.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1e52bb3-44963.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?