An array of javascript

Source: Internet
Author: User

Since I have been learning programming, I have not been able to understand the difference between objects and arrays, in fact, this is a very brain problem, arrays and objects should be well differentiated, arrays used to store multiple values in a single variable

Create an Array object

New Arrray ();

Nwe Array (size);

New Array (Ele0,ele1...elen);

Parameters

The parameter siz is the expected number of elements, the returned array, and the length field is set to the value of size.

Parameter Ele0,ele1...elen is a list of parameters that are initialized to these values when the constructor array () is called with these parameters. Its length field is also set to the number of parameters.

return value

Returns the newly created array that was initialized.

If a parameter is not used when calling the constructor array (), then the undo array is empty and the length field is 0.

When the call constructor thing is passed only to it a numeric parameter, the constructor returns an array with the specified number of elements as undefined.

When an array () is called by another parameter, the constructor initializes the array with the value specified by the parameter.

When a constructor is called as a function, and the new operator is not used, its behavior is exactly the same as when it is called with the new operator.

Array Object Properties

Constructor returns a reference to the array function that created this object.

Length Sets or returns the number of array elements

Prototype gives you the ability to add properties and methods like objects

Concat () joins two or more arrays and returns the result.

Join () Places all elements of an array into a string. element is delimited by the specified delimiter.

Pop () deletes and returns the last element of the array

Push () adds one or more elements to the end of the array and returns the new length.

Reverse () Reverses the order of the elements in the array.

Shift () deletes and returns the first element of the array.

Slice () returns the selected element from an existing array

Sort () Sorts the elements of an array.

Splice () Deletes the element and adds a new element to the array.

Tosource () returns the source code of the object

ToString () shifts the array to a string and returns the result

toLocaleString () converts the array to a local array and returns the result

Unshift () adds one or more elements to the beginning of the array and returns the new length.

ValueOf () returns the original value of the array object.

An array of 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.