Rookie front-end programmer small Knowledge point brocade set two

Source: Internet
Author: User

1. Array sorting
Array---the sort () method;
1> sorts the letters using the Sort method:
var arr=new Array (6)
Arr[0]=a. Arr[1]= ...
Arr.sort ();
To be discharged in a A-Z order
2> sorts numbers by using the Sort method:
Arr.sort (sortnumber); Sort the numbers from small to large.
3> If you sort by other criteria, you need to provide a function,
Arr.sort (function () {});
This function returns a value greater than 0 from the large to the small sort;
Values less than 0 are sorted from small to large;
Arr.sort (function (b) {
return a-B;
});
4> the JSON object (where the JSON object has been converted to a string form)
A and B can be regarded as a less than B;
if: arr=[{score:30},{score:60},{...},{...},{...}]
Can do this:
Arr.sort (function (b) {
return a.score-b.score;
});
An array of JSON objects is sorted by a property to this set of JSON objects.
2. Which conditions will generate BFC
1> root element (body itself is a BFC)
2> the Float property is not none;
3> position for absolute or fixed
4> Display for Inline-block,table-cell,table-caption,flex,inline-flex
5> overflow is not visible;
3, how to use Localstorage to store an object
1> creating an array in Localstorage
var players=localstorage.players;
if (!players) {
Players=[];
}
2> put the value of an array into an array
var p={name:111,score:222}
Players.push (P);

3> to convert objects to string form
Localstorage.players=json.stringify (players);
4. How to convert objects in string form to JSON objects
Players=json.parse (players);//Refer to the above players.
5. CSS Selector priority level
1> inline style special value 1000;
2> ID Selector special value 0100;
3> Class (pseudo Class) selector special value 0010;
4> element Selector special value 0001;

Rookie front-end programmer small Knowledge point brocade set two

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.