JS Delete array sort definition element (1/3)

Source: Internet
Author: User

There are no methods that include IE and FF that are not compatible:
ToString (): Converts an array to a string
toLocaleString (): Converts an array to a string
Join (): Converts an array into a symbolic concatenated string
Shift (): Moves an element of an array's head out
Unshift (): Inserts an element in the header of an array
Pop (): Deletes an element from the tail of an 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 in reverse order
Sort (): Sorting operations on array
Splice (): Inserts, deletes, or replaces an array element

ToString () method, toLocaleString () method of the role is similar to the role of FF is exactly the same, ie if the element is a string, will be in the "," followed by a space, if the element is a number, will expand to two decimal places, Both change the length property of the string, so consider compatibility and try not to use the toLocaleString () method.

<script>
var a = new Array (1, 2, 3, [4, 5, [6, 7]])
var B = a.tostring ()//b "1, 2, 3, 4, 5, 6, 7" in string form
var c = new Array (1, 2, 3, [4, 5, [6, 7]])
var d = c.tolocalestring ()//d "1, 2, 3, 4, 5, 6, 7" in string form
Both the ToString () method and the toLocaleString () method can disassemble a multidimensional array
</script>


The join () method converts all elements in an array to strings, and then joins together, which is exactly the opposite of the string's split () method. Join () By default is using "," as the separator, of course, you can also specify the separator in the method

<script>
var a = new Array ("A", "second", "third")
var s = a.join ("...")
document.write (s)
The result shown is "First...second...third"
</script>

Home 1 2 3 last

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.