Length PropertyDefinition and usage
The length property can set or return the number of elements in the array. This is very common.
Grammar
Arrayobject.length
Prototype PropertyDefinition and Usage
The prototype property gives you the ability to add properties and methods to an object.
Grammar
Object.prototype.name=value
Example
In this example, we will show how to use the prototype property to add properties to an object:
1<script type= "Text/javascript" >2 //constructor Function3 functionEmployee (Name,job,born)4 {5 This. name=name;6 This. job=job;7 This. born=born;8 }9 //new instance, Bill, he inherits all the attributes of employeeTen varBill=NewEmployee ("Bill Gates", "Engineer", 1985); One //Add the Salary property to the employee prototype Aemployee.prototype.salary=NULL; - //This property can be inherited by Bill to -bill.salary=20000; the - document.write (bill.salary); - -</script>
Output:
20000
Constructor property
The constructor property returns a reference to the array function that created this object.
<script type= "Text/javascript" > // constructor Function function Employee (Name,job,born) {this. name=name; this. job=job; this. born=born;} var bill=New employee ("Bill Gates", "Engineer", 1985);d Ocument.write (bill.constructor); </script>
Output:
1 function Employee (name, JobTitle, born) 2 {this this. Born = born;}
The result is that the constructor that created it is returned
Three attribute instances of the array object