Operation of the "JavaScript" string

Source: Internet
Author: User

First, the common operation

ToString (): Converts an array to a string
toLocaleString (): Converts an array to a string
Join (): Converts an array to a symbolic concatenated string
Shift (): Moves an element of the array head out
Unshift (): Inserts an element in the head of an array
Pop (): Deletes an element from the tail of the array
Push (): Adds an element to the tail of the array
Concat (): Adding elements to an array
Slice (): Returns the part of an array
Reverse (): Sort the array backwards
Sort (): Sort operations on an array
Splice (): Inserting, deleting, or replacing an array element

Second, delete the array to specify the subscript element code

<script>var arr = [' A ', ' B ', ' C ', ' d ', ' e ']; function Arr_del (d) {    return arr.slice (0,d-1). Concat (Arr.slice (d));} Alert (Arr_del (//  a,b,d,e</script>

Slice method Summary: Join Arrayobj=[george,john,thomas,james,adrew,martin]

1) arrayobject.slice (start,end) Gets the [start, end] element, containing start without the End,arrayobj.slice (2,4) result as Thomas,james

2) Arrayobject.slice (d) Gets the [D,end] element, starting from D until the end, Arrayobj.slice (4) results are Adrew,martin

Iii. Methods of Concat

You can concatenate two or more arrays without changing the existing array, returning only the copy of the connected array!

Array1 = [+];  array2=[3,4]; array=[5,6]

1) Connection value

Array1.concat (4,5) array1 unchanged, but the returned array is [1,2,4,5]

2) Connect two or more arrays

Array1.concat (array2) returns an array of [1,2,3,4]

Array1.concat (ARRAY2,ARRAY3) returns an array of [1,2,3,4,5,6]

Operation of the "JavaScript" string

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.