JS bits and pieces of knowledge

Source: Internet
Author: User

Tag:org    Regular expression    div   sort   data    func   write    greater than     string array    

The filter () method filters the array, generating a new set of var aqinewdata = Aqidata.filter (function (data) {return data[1]>60;}); Make a new array of data greater than 60. The sort () method sorts the new array from large to small. Aqinewdata.sort (function (A, b) {return b[1]-a[1];}); If replaced by a[1]-b[1] is from small to large sort. The Createdocumentfragment () method of creating virtual (fragmented) nodes makes it more secure to change the structure and nodes of the document. This node is then appended to the parent node. The Replace (A, B) method is used to replace characters with some characters in a string, or to replace a substring that matches a regular expression. Replacing a with B,ab can be a string. The split () method is used to split a string into an array of strings. <script type= "Text/javascript" >var str= "How is you doing today?" document.write (Str.split ("") + "<br/>") document.write (Str.split ("") + "<br/>") document.write (str.split ("", 3)) </script> output results: How,are,you,doing,today? H,o,w,, A,r,e,, Y,o,u,, D,o,i,n,g,, T,o,d,a,y,? The How,are,you Join () method is used to put all the elements in an array into a string. The elements are delimited by the specified delimiter. <script type= "Text/javascript" >var arr = new Array (3) arr[0] = "George" arr[1] = "John" arr[2] = "Thomas" Document.writ E (Arr.join ()) </script> output: george,john,thomas If you change to join ("), the output is George John Thomas.

JS bits and pieces of knowledge

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.