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 ;}