About JavaScript (scripting language)

Source: Internet
Author: User
Tags switch case

1. typeof operator: Determines what type an object is, returns ""

First, Number type

1, JavaScript is not good at calculation, can not be used for floating-point calculation. such as: var a = 0.2;  var B = 0.1; -A + b = 0.3000000000000004

2, Nan means non-numeric

3. Number: Convert objects to numbers

4. parseint: Resolves an object to an integer

5. parsefloat: Resolves the object to a floating-point number

%%%%%%%%%%%% Here are a few things to keep in mind

6. Strings with a length greater than 0 are true

7, 0 is False

8, Nan non-digit is false

9, empty string is False

10. Numbers greater than or equal to 1 are true

Two, String type

1. String: Casts the object to a string type

Switch (case)

1, compared to the C # switch (case), JS in the switch (case) can be run through, that is, a case can not break

2, can be directly behind the switch case without prior declaration

The relationship between numbers and strings in JS

1, the string in JS is a value type

2, JS in the + number has the function of the connection string:

var num1 = 5;var num2 = 10;

var result1 = num1 + "5"; -RESULT1 = 55 (numeric + string)

"The sum of 5 and Ten is" + NUM1 + num2; -"The sum of 5 and is 510"

"The sum of 5 and Ten is" + (NUM1 + num2); -"The sum of 5 and is 15" (shown to do the number calculation) and compare above

3. Logical judgment of String (Boolean)

The ternary operation in JS

The special case of the division parameter in JS (Infinity Infinity)

alert (5/nan); NaN

alert (infinity/infinity); Nan Non-numeric

alert (INFINITY/2); Infinity Infinity

alert (5/0); Infinity

alert (10/true); Ten true is essentially 1
alert (10/false); Infinity false

The equal operation in the six, JS

1, "= = =" means congruent, requires not only equal value, the same type. Special case: Alert ("+")-"true" because there will be conversions between them but alert (55 = = = "55"); -"false" (number type and string type)

About JavaScript (scripting language)

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.