Type, value, and variable (i)

Source: Internet
Author: User
Tags arithmetic operators

(i) JavaScript type

1. JavaScript data types have a total of 6 in the ES5 Standard: Numbers, strings, Booleans, null,undefined, objects. The first five are known as primitive types, and objects are object types. Objects also include our commonly used arrays and functions.

2. The original data type of Javasript is generally not changed, but the object type can be changed.

(ii) Number

1. Integral Type Direct Quantity

(1) ES supports decimal and hexadecimal. Where hexadecimal starts with ' 0x ' or ' 0X '

(2) The ES standard does not support octal, but in some implementations it is possible to allow an octet (starting with 0). Note that in ES6 strict mode, octal is forbidden by the command

2. Floating-point Direct volume

(1) Traditional real-number notation

(2) Exponential counting method

3. Arithmetic operators

(1) +-*/%

(2) The various methods of math

4. Overflow, underflow, and divide by zero

(1) The result of overflow is positive infinity or negative infinity

(2) The result of Underflow is infinitely close to 0, directly about equal to 0

(3) The result of being divisible by 0 is infinitely large.

(4) 0/0 = = = NaN

Note: overflow, underflow and zero are divisible in JS will not error

5. nan,infinity,-0

(1) Nan is a non-numeric character that is not equal to anyone, including itself. The way to judge it is when X! =x is the truth, X is Nan

Give any negative number a value of Nan

Infinity divided by Infinity value is Nan

(2) Infinity,-infinity

Infinity divided by infinity, Nan

Infinitely large Any subtraction operation results are infinite

(3) 0 = = = 0

1/0!== 1/-0

6. The binary floating-point number is error, so in the financial class calculation is, should try to use integer units to calculate, for example, 1 points in the unit partition calculation, rather than the unit element

0.3-0.2! = = 0.2-0.1

7. Dates and times date () and a series of corresponding methods

(ii) text

1. Each character in the string occupies a 16-bit value. There is no character type in JS, which means a single character string with a length of 1.

2. Note the use of single and double quotes

3. Strings can be wrapped in ES5, but end with ' \ ' at the end of each line

4. Escape character

5. Use of strings

(1) +: String connection

(2) Length property

(3) Other methods, but note that the value of the string is constant, you can return a new string but you cannot change the value of the string

(4) Access to characters in the string two methods, the first is Charat (), the second is []

(c) Boolean value

1. True, False

2. ToString ()

3. &&, | |,!

(d) NULL, undefined

1. Null

(1) indicates null value

(2) The result of the TypeOf operation is ' object ', but it is usually considered to be the only member of the free type

2. Undefined

(1) Vacancy indication

(2) When the function does not return a value, return undefined

(3) When the variable used is undefined, return undefined

(4) When the accessed array element or object attribute does not exist, return undefined

3. Null and undefined

(1) NULL = = undefined---true

(2) NULL = = undefined----false

(3) does not contain any methods and attributes

(4) When you need to assign a null value to a variable or attribute, or pass in a function as a parameter, NULL

Type, value, and variable (i)

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.