JavaScript statement semantics Daquan (2)

Source: Internet
Author: User

1. Arithmetic related

+,-,*,/,%

The subtraction and the remainder, respectively.

2.math.pow (A, B)

A's B-square

3.toFixed (a)

Rounds a number to a specified number of decimal digits

4. k++;

++k

It looks the same, but there are some tiny differences in the operation.

var k=0

Alert (k++)

Alert (++K)

Of the two equations above, the result of the first one is 0, the second one is 1.

For example: alert (++k + k++ + ++k + k);

In the formula, the first execution ++k, this time K is +1 at the same time, ++k immediately effective, so the formula becomes: Alert (1 + k++ + ++k + K); K=1

Immediately thereafter, the execution k++,k is 1, but the k++ value remains 1, so the result is: alert (1 + 1 + ++k + k); k=2

Then ++k executes, K becomes 3--alert (1+ 1 + 3 + k); k=3

Finally executes +k, becomes alert (1+1+3+3); k=3

Result is 8

5. IsNaN (v)

Whether it is a number

6.

switch (i) {
Case 0:

CASE1:

Alert ("AAA");

Break

A conditional statement that executes the corresponding statement when the value of I and the following case value are the same. Note that there is a word: break, which means that if you do not jump out, then after you execute sentence A, the program will continue to execute a+1,a+2 until a jump statement exists.

7.

var _name = "Background";
_div.style[_name] = _value;//_name refers to a variable, which refers to the string "background"
_div.style._name = _value;//_name is not a property of style, so it cannot be found

8.

ToString (2)//decimal to Binary

parseint (10, 2)//10 is represented by a binary and returns its decimal

JavaScript statement semantics Daquan (2)

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.