About JS knowledge, math (Math object)

Source: Internet
Author: User
Tags mathematical functions

November 24, 2016, Thursday


First, theoretical knowledge:

1. An equal sign = delegate assignment;

2. Sequence of operations: from right to left;

3. Mathematical operators: +-*%/^;

4. Scientific notation: 1E3;

Second, the experiment Code:

650) this.width=650; "Src=" Http://s5.51cto.com/wyfs02/M01/8A/AC/wKiom1g2yZzjjZMVAAE9LU_ZGCs101.png-wh_500x0-wm_3 -wmp_4-s_1060662351.png "title=" 2016-11-24_190512.png "alt=" Wkiom1g2yzzjjzmvaae9lu_zgcs101.png-wh_50 "/>

Third, the theory:

1.a++ equals a =a+1;

The order of a++ is first assigned and then calculated.

Code:

<script>

var a = 10;

var b = 1;

A = a+1;

b =++a;

document.write (a);

</script>


2. String connector: +

<script>

var Varnaisa = "1";

var Varliao = "11 Today";

Number converted to string output: 111 today.

var a = 1+ "11 Today";

var A=varnaisa+varliao;

document.write (a);

</script>

Iv. Mathematical Functions, fractional rounding:

Math.ceil: All to the upward position.

Code:

<script>

var a=1.009;

var b=math.ceil (a);

document.write (b);

</script>


2.math.round: Rounds rounding.

Code:

<script>

var a=1.94;

var b=math.round (a);

document.write (b);

</script>
3.math.floor: rounding

Code:

<script>

var a=1.94;

var B=math.floor (a);

document.write (b);

</script>


Mathematics function, Pi

Expression: Math.PI;

Code:

<script>

var a=50;

var B=math.pi;

var Varint=a*a*math.pi;

document.write (varint);

</script>

Six, extract a substring:

Expression: String.substr

Code:

<script>

var a= "7853.981633974483";

var b=a.substr (0,10);

document.write (b);

</script>

Seven, calculate how many times the equation:

Expression: Math.pow;

Code:  

<script>

var a=math.pow (2,10);

document.write (a);

</script>





About JS knowledge, math (Math object)

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.