Let's talk about the difference between brackets and no brackets for constructors.

Source: Internet
Author: User

Let's talk about the difference between brackets and no brackets for constructors.

As follows:

// First define a constructor Hellofunction Hello () {alert (1) ;}// define a function expression var getName = function () {alert (2 );} // instantiate the object. If the following two constructors do not have any form parameters, the constructor can not be added with parentheses (recommended) during instantiation; var p = new Hello; var p1 = new Hello (); // when calling the getName function in the following method, the constructor may have different parentheses. new Hello. getName (); // the execution order is to execute Hello first. getName (), and then use the new keyword; new Hello (). getName; // This is an object first new Hello (), and then the object calls the getName method;

The difference between the brackets and the parentheses in the above detailed section is the whole content shared by the editor. I hope to give you a reference, and I hope you can also provide more support for the customer's house.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.