The constructor attribute of the javascript Array object, arrayconstructor

Source: Internet
Author: User

The constructor attribute of the javascript Array object, arrayconstructor

Definition and usage
The constructor attribute returns a reference to the array function that creates this object.

Syntax
Object. constructor

Example:

<Script type = "text/javascript"> var test = new Array (); if (test. constructor = Array) {document. write ("This is an Array");} if (test. constructor = Boolean) {document. write ("This is a Boolean");} if (test. constructor = Date) {document. write ("This is a Date");} if (test. constructor = String) {document. write ("This is a String") ;}</script>

Print:

This is an ArrayTIY

Example 2:

<Script type = "text/javascript"> function employee (name, job, born) {this. name = name; this. job = job; this. born = born;} var bill = new employee ("Bill Gates", "Engineer", 1985); document. write (bill. constructor); </script>

Print:

Function employee (name, jobtitle, born)
{This. name = name; this. jobtitle = job; this. born = born ;}

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.