JavaScript language basics 5: javascript language basics

Source: Internet
Author: User

JavaScript language basics 5: javascript language basics

About numerical calculation and character operations

The following code is used for analysis:

<span style="font-size:14px;"><HTML><HEAD><TITLE>Hello World</TITLE></HEAD><BODY BGCOLOR="WHITE"><SCRIPT Language="JavaScript" TYPE="text/javascript">var value1;value1=2.1+3;document.write(value1+"    ");value1=5-3;document.write(value1+"    ");value1=3*3.4;document.write(value1+"    ");value1=6/2;document.write(value1+"    ");var value2=1;value2++;document.write(value2+"    ");value2--;document.write(value2+"    ");var value3=4;++value3;document.write(value3+"    ");--value3;document.write(value3+"    ");var value4;var value5=8;value4=value5++-1;document.write(value4+"    ");value5=8;value4=--value5-1;document.write(value4+"    ");document.write("Hello "+"World"+"    ");document.write("Hello"+123);</SCRIPT></BODY></HTML></span>

The effect is as follows:


JavaScript supports various basic mathematical operations, defining the variable value1 for addition, subtraction, multiplication, and division.

In JavaScript, auto-increment (++) and auto-increment (--) are also supported (--)

The above Code focuses on these two sentences.

<span style="font-size:18px;">value4=value5++-1;</span>
<Pre name = "code" class = "javascript"> <span style = "font-size: 18px;"> the result is 7. </span>
<Span style = "font-size: 18px;"> it can be seen that the value5-1 is assigned to value4 first, then value5 auto increment, so the result is 7 </span>
<span style="font-size:18px;">value4=--value5-1;</span>
<Span style = "font-size: 18px;"> the result is 6. </span>
<Span style = "font-size: 18px;"> calculation process: first, the value5 is automatically subtracted, and then 1 is subtracted. The result is 6. </span>

 

JavaScript also supports adding characters. You can use the + sign to connect the characters together. You can also add the characters and numbers.


Reprinted please indicate the source: http://blog.csdn.net/hai_qing_xu_kong/article/details/40804789 sentiment control _



There is no JavaScript Foundation. How long does it take to learn jQuery separately? Five hours a day

Learn html and css first.
JQuery can be used in just one day when we know about the two above.

How to Learn JavaScript

1. It is best to learn C language well. C language is the foundation of the basics, and then it is easy to understand JavaScript.
2. There are a lot of JavaScript tutorials on the Internet.

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.