Walkthrough of JavaScript operator Instance

Source: Internet
Author: User
Tags arithmetic operators logical operators string

Core tips: Walkthrough of JavaScript operator Instance

Depending on the number of objects processed:

Cell operator;

binary operator;

Ternary operator.

According to the function:

Assignment operator;

= + = = *=/=%= (take more)

arithmetic operators;

+-*/% (remainder) + + (incremental)--(descending)-

Example 1:

Example 2:

<br/><Script> <br/>var x = y = 3; <br/>with (document) {<br/> write ("x = 3, y = 3 <br>"); <br/> Write ("If x = after y++ operation:"); &L t;br/> x = y++;//y→x,y+1→y <br/> Write ("x is", X, "; Y is ", Y, <br>"); <br/> write ("Again x = ++y operation:"); <br/> x = ++y;//y+1→x,y+1→y <br/> Write ("x is", X, "; Y is ", y); <br/>} <br/></Script>
string operators;

+ + =

comparison operators;

= =!= = = = (value and type)!== (value and type)

< <= > >=

Cases:

<br/><Script> <br/>var x = 5; X is the value 5 <br/>var y = ' 5 '; Y is the string 5 <br/>var z = 6; X is the value 6 <br/>with (document) {<br/> write ("x = 5, y = ' 5 ', z = 6"); <br/> write ("<li>x = = y? ", x = = y); <br/> Write ("<li>x = = y?") ", x = = y); <br/> write ("<li>x!= y?") ", x!= y); <br/> write ("<li>x!== y?") ", x!== y); <br/> write ("<li>x <= z?") ", x <= z); <br/> write ("<li>y <= z?") ", y <= z); <br/>/Type automatic conversion <br/>} <br/></Script>
logical operators;

&&!

Example 1:

<br/><Script> <br/>var t = true; <br/>var F = false; <br/>with (document) {<br/>write (Result of "<ol><li>true && true", T && t); <br/>write ("<li>true && false result is", T && F); <br/>write (Result of "<li>false && true", F && t); <br/>write ("<li>false && false result is", F && f); <br/>write ("<li>true && (1==1) results are", T && (1==1)); <br/>write (The result of "<li>false && ' A" is ", F && ' a"); <br/>write ("<LI> ' a ' && false result is", ' a ' && f); <br/>write (The result of "<li>true && ' A" is ", T && ' a '); <br/>write ("<LI> ' a ' && true result is", ' a ' && t); The result of <br/>write ("<LI> ' a ' && ' B ') is", ' a ' && ' B '); <br/>    //&&amp: One is not a logical value, the value of the first operand is returned flase if the value of the first operand is flase, otherwise the value of the second operand is returned &LT;BR />} <br/></Script>

1 2 Next page > full text reading tips: Try "←→" button, turn the page more convenient Oh!

[1] [2] Next page



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.