The array object in JavaScript

Source: Internet
Author: User
1. Create an Array object
Syntax for creating an array object
var array name = new Array ();
After the array is defined. You need to add elements to the array. Formats such as the following
Array name [< subscript >]= value;


2. Array Object Properties
The array object provides only 4 properties
Index: The character matches the position of the string, or the return-1 is not found
Input: Specifies the original string that matches the normal table expression
Length: Returns the size of the array, that is, how many elements are in the array, which makes it easy to traverse the log group
Prototype: Adds a newly defined property or method to the array object, and then an instance of the object can invoke the property or method


3. Array Object method
Concat (): For object link Reference, copy its value for character or string
Join (): All elements separated by the specified delimiter
Pop (): Removes the last element from the array and returns the element, assuming the array is empty. Then return to underfined
Push (): Appends new elements in the order in which they appear
Shift (): Removes the first element in the array and returns it
Unshift (): Inserts these elements at the beginning of an array so that they are sorted by their order in the tables
Reverse (): Rearrange the elements of the array in the direction opposite to the original
Sort (): Returns the sorted array object, with default elements sorted in ascending order of ASCII characters
Splice (): Changes the array by removing the specified number of elements starting at the start position and inserting a new element. The return value is a new array object that consists of the elements that are removed
Tolocalstring (): Returns a value in the form of a string value. This value is appropriate for the locale of the current environment
ToString (): Returns the string representing the object
ValueOf (): Returns the original value of the specified object

The array object in JavaScript

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.