3. Types, values and variables-javascript authoritative guide notes

Source: Internet
Author: User

began to become interesting, but the third chapter is to understand the basic knowledge of the concept of interpretation of the relevant concepts, and did not go deep into the combination of code and the functions to be implemented in terms of usage and principles of the degree.

1. Introduction.

Value: The operation of the program is a function of the value.

Type: A value that can be represented and manipulated, and whose type is called the data type. The basic feature of programming languages is the ability to support multiple data types.

Variable: A variable is a symbolic name for a value, and a reference to that value is obtained by name.

JavaScript data types are divided into: primitive type-primitive type; object type-object type.

The JavaScript interpreter can automatically recycle memory (garbage Collection): The program can create objects on demand, object destruction and memory reclamation are the responsibility of the interpreter, and when no longer any references point to an object, the interpreter automatically reclaims the memory resources it consumes. This is realized when paging is used in the variable of Out _count (the life cycle of the variable).

JavaScript variables are untyped (untyped), using the var keyword declaration (DECLARE) variable.

2. Digital

All the numbers in JavaScript are represented by a 64-bit floating point (IEEE754 standard), and the integer operation is based on an integer of 32.

The number that appears in the JavaScript program becomes the direct amount of the number. It is important to note that negative numbers are calculated by a positive number. The minus sign that is added is a unary negation operator, and the minus sign is not the composition of the digital direct amount.

Octal direct volume starts with 0, some places may not support octal parsing, hexadecimal starts with 0x, decimal direct write is not prefixed with 0, floating-point direct volume is also directly written. (. 2 is 0.2)

Number of arithmetic operations occur overflow, underflow, by 0 in addition to the time does not error, the corresponding return positive and negative infinity infinity, underflow is the result of zero, the direct return plus or minus 0, by 0 in addition to return positive and negative infinity, 0 in addition to 0 is meaningless. Nan represents not-a-number, non-numeric meaning, and also a value, and any value (including itself) is unequal.

A few interesting points: X! = x This sentence is true only when X is Nan, so you can use this sentence to determine whether the value is Nan, minus 0 = positive zero, and the symbol is represented as ±infinity when doing division.

As mentioned before, the number is expressed in floating-point type, the decimal number is approximate, and there will be 0.3-0.2!=0.2-0.1. So when writing conditional judgments and so on, pay attention to rounding errors, and of course integers do not have this problem.

The use of the Math object and the date () constructor, when required, to refer to the API itself.

3. Text

strings, string, each character from the Unicode character set, each long 16bits,2bytes. The string is therefore zero-based, and a single character is a string of length 1.

It is important to note that all operations on strings in JavaScript are based on 16-bit values and do not target individual characters.

String direct, single or double quoted character sequence, to here finally know what the direct volume is a concept ... The empty string "" contains 0 characters, not null.

Long string does not wrap, ECMASCRIPT3 does not support, 5 words can be at the end of a line with \. HTML is also single and double quotes can be = =. Escape character you know, don't say much.

Also, in JavaScript, when a string appears once, its value is fixed, and the result of the change will be the new string, the original string, or the original value.

Regular Expressions: regular expression. This chapter only needs to know so much good.

4. Boolean values

It's a regular thing here. There are some special places for weak types of JavaScript.

Undefined, null, ±0, NaN, "" (empty string) can be converted to a Boolean value of false, and all remaining values will be converted to true.

For the distinction of false value, we need to use!== or = = = To do explicit comparison. Null = = undefined is true, NULL = = undefined is false.

5.null and undefined

Null is the only member of its own type, is the keyword; undefined is a predefined global variable whose value is undefined, read-only, non-keyword.

6. Global object.

This is actually a bit of a relationship with the scope. The global object is something that can be used directly, the JavaScript interpreter starts, or when the browser loads a new page, it creates a new global object and gives it a defined set of initial properties: Global attribute Undefined, global function isNaN (), constructor date (), etc., Global object, math, and so on.

7. Summary

Or at the basic conceptual stage, there are a lot of new things (things that differ only from Java and C #).

Today, the study of JS is here.

  

3. Types, values and variables-javascript authoritative guide notes

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.