How to use the JavaScript new operator

Source: Internet
Author: User

New operator
Creates a new object.

newconstructor[(arguments)]

Parameters
Constructor

Required option. The constructor of the object. If the constructor has no arguments, you can omit the parentheses.

Arguments

Options available. Any arguments passed to the new object constructor.

Description
The new operator performs the following tasks:

Creates an object that has no members.
Call the constructor for that object, passing a pointer to the newly created object as the this pointer.
The constructor then initializes the object based on the arguments passed to it.
Example
These are examples of usages of a valid new operator.

My_object =newobject;my_array =newarray (); My_date =newdate ("5 1996");

<body>
<script language= "JavaScript" >
<!--
var myarray = new Array ();
-->
</script>
</body>

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.