I know the difference between two in C++, but don't know if it's the same for JS also
From my experience there is no difference other then with new Foo
you can't pass any parameters and with new Foo()
you can.
From the ECMAScript Language Specification for new
:
new NewExpression:
Call the [[Construct]] method on Result(2), providing no arguments
new MemberExpression Arguments
Call the [[Construct]] method on Result(2), providing the list Result(3) as the argument values.
It's simply a matter of whether the constructor receives any arguments or not.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With