JS Common function Use small memory

Source: Internet
Author: User

The Concat () method is used to concatenate two or more arrays.

The method does not alter the existing array, but only returns a copy of the concatenated array.

var a = [Ocument.write];d (A.concat (4,5));

The shift () method removes the first element from the array and returns the value of the first element.

var New Array (3) arr[0] = "George"arr[1] = "John"arr[2] = "Thomas"+ "<br/>"  + "<br/>") document.write (arr)

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

var New Array () arr[0] = "George"arr[1] = "John"arr[2] = "Thomas"+ "<br/>") document.write (Arr.unshift ("William") + "<br/>") document.write (arr)

The join () method is used to put all the elements in an array into a string.

The elements are delimited by the specified delimiter. A join can take parameters, including specific separators such as:

var New Array (3) arr[0] = "George"arr[1] = "John"arr[2] = "Thomas"document.write (Arr.join ()) document.write (Arr.join (': '))

The Pop () method is used to delete and return the last element of the array.

<script type= "Text/javascript" >varnew Array (3) arr[0] = "George"arr[1] = " John "arr[2] =" Thomas "document.write (arr) document.write (" <br/> ") document.write ( Arr.pop ()) document.write ("<br/>") document.write (arr)</script>

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

var New Array (3) arr[0] = "George"arr[1] = "John"arr[2] = "Thomas"+ "<br/>") document.write (Arr.push ("James") + "<br/>") document.write (arr)

The reverse () method reverses the order of the elements in the array.

<script type= "Text/javascript" >varnew Array (3) arr[0] = "George"arr[1] = " John "arr[2] =" Thomas "+" <br/> ") document.write (Arr.reverse ())</script>

The delete operator removes a reference to a previously defined object property or method.

var New  = "David"; alert (o.name);     // output "David" Delete O.name;alert (o.name);     // output "undefined"

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.