- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
What are the properties of an array object in JavaScript?
The Array object lets you store multiple values in a single variable. It stores a fixed-size sequential collection of elements of the same type.
The following is the list of the properties of the Array object −
Sr.No | Property & Description |
1 | constructor Returns a reference to the array function that created the object. |
2 | index The property represents the zero-based index of the match in the string. |
3 | input This property is only present in arrays created by regular expression matches. |
4 | length Reflects the number of elements in an array. |
5 | prototype The prototype property allows you to add properties and methods to an object. |
Example
Let’s see an example of the prototype property
<html> <head> <title>JavaScript Array Object</title> <script> function book(title, author){ this.title = title; this.author = author; } </script> </head> <body> <script> var myBook = new book("Java", "John"); book.prototype.price = null; myBook.price = 300; document.write("Book title is : " + myBook.title + "<br>"); document.write("Book author is : " + myBook.author + "<br>"); document.write("Book price is : " + myBook.price + "<br>"); </script> </body> </html>
Output
Book title is : Java Book author is : John Book price is : 300
Advertisements