Based on the 02.JavaScript

Source: Internet
Author: User

Operator

Arithmetic: + Plus, minus, * multiply,/divide,% modulo example: interlaced color, seconds turn time
Assignment values: =, + =,-=, *=,/=,%=
Relationships:<, >, <=, >=, = =, = =,! = (unequal),!==
Logical:&& with (and), | | Or! No example: Select All and reverse selection
Operator Precedence: parentheses

arithmetic : + Plus, minus, * multiply,/divide,% modulo (take remainder)
Alert (12%5) Popup 2 fetch remainder
Interlaced discoloration (modulus)

<script>window.onload=function (){    varAli=document.getelementsbytagname (' Li ');  for(vari=0;i<ali.length;i++)    {        //I 0 1 2 3 4 5 6 ... ..        if(i%2==0)        {            //0 2 4 6 8Ali[i].style.background= ' #CCC '; }        Else        {            //1 3 5) 7 9Ali[i].style.background= "; }    }};</script><ul> <li></li> <li></li> <li></li> <li></li&    Gt    <li></li> <li></li> <li></li> <li></li> <li></li> <li></li> <li></li></ul>
View Code

Seconds calculation

<script>var s=1345; alert (parseint (s/60) + ' +s%60+ ' seconds ');</script>
View Code

Assignment values : =, + =,-=, *=,/=,%=

I=i+1
I+=1
i++ are self-increasing but + + can only add 1 at a time

I=i+3
I+=3 Add 3 each time

relationships :<, >, <=, >=, = =, = =,! = (unequal),!==

logical :&& with (and), | | Or! No example: Select All and reverse selection
! Take counter

Alert (TRUE); The Popup is True
alert (!true); The pop-up is false
Alert (!! true); The Popup is True

Program Flow Control

Judgment: If, switch,? Tri-Wood operation:
Loops: while, for
Jump: Break broken terminal, continue continue
What is true and what is false:
true: true, non-0 numeric, non-empty string such as (' ') has a space , non-empty object summary: There's something real .
False: false, number 00, empty string For example ("'), null for empty object, undefined summary: nothing is fake.

if (condition) {statement 1}else{Statement 2}
if (condition 1) {statement 1}else if (condition 2) {statement 2}else if (condition 3) {statement 3}......else{Statement n} can have countless else if{}, but only one else{}

Switch (variable)
{
Case value 1:
Statement 1
Break
Case Value 2:
Statement 2
Break
......
Default
Statement n
}

<script>var name= ' Blue '; var sex= '; Switch (Sex) {    case ' man ':        alert (name+ ' Mr. Hello ');           Break ;      Case ' Woman ':        alert (name+ ' lady, hello ');          Break ;     default :        alert (name+ ' Hello ');} </script>
View Code

Trinocular operator
Condition? Statement 1: Statement 2 is equivalent to if (condition) {statement 1}else{Statement 2}

<script>var a=14; /* if (a%2==0) {    alert (' Even-numbered ');} else{    alert (' singular ');} */ a%2==0?alert (' Even-numbered '): alert (' singular '); </script>
View Code

Break interrupted
Continue continue

<script>for (var i=0;i<5;i++) {if(i==2) {//  break;    The entire cycle was interrupted      only to eject 0 1 behind the terminals of the continue;    // This cycle is interrupted     only pop-up 0 1 3 4 Only this time the one jumped off }alert (i);} </script>
View Code

What is JSON

JSON format json={Name: value, Name: value, First name: value}

<script>/*var a=12;var b=5;var c= ' abc '; */ var json={a:12, B:5, C: ' abc '};json.b+ +; alert (json.b); </script>
View Code

The difference between JSON and array

var json={a:12, B:5, c:7};
var arr=[12, 5, 7];

Alert (JSON.A)//equals alert (json[' a ');
Alert (arr[0]);

Compare the differences between the two
Alert (json[' a ');.
Alert (arr[0]);
The subscript of the JSON is the subscript of the string array is the number
alert (arr.length); Get is 3
alert (json.length); Get is undefined no length

Array loops
The first loop of an array
for (Var i=0;i<arr.length;i++)
{
Alert (' +i+ ' thing: ' +arr[i]);
}

The second loop of the array
for (var i in arr)
{
Alert (' +i+ ' thing: ' +arr[i]);
}
JSON loop

for (var i in JSON)
{
Alert (' +i+ ' thing: ' +json[i]);
}

There are two loops in the array and JSON loop array with only one loop



Based on the 02.JavaScript

Related Article

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.