JavaScript Advanced Programming (summary in the book)

Source: Internet
Author: User
Tags modulus

Note: This article belongs to the personal summary, the knowledge point is not complete, the wrong place, also hope forgive me. (I will revise it in the future, correction)

This book: the introduction of JS and the use of HTML in the skip. (Straight to the basic grammar, and the filter section during the period)

Chapter Three: Basic concepts:

Everything in 1.js (variables, function names, and operators) is case-sensitive;

2. An identifier refers to the name of a variable, function, property, or parameter of a function. Identifiers can be one or more characters that are combined according to the following formatting rules:

(1) The first character must be a letter, an underscore (_), or a dollar sign ($);

(2) Other characters can be letters, underscores, dollar signs, or numbers.

3. Statement:

var sum = a + b//Even if no semicolon is a valid statement--not recommended

var diff = a-b; Valid statements--recommended

4. Variables: JS variables are loosely typed and can be used to hold any type of data. Use the var operator when defining a variable (note that var is a keyword) followed by the variable name (that is, an identifier)

such as: Var message; This variable is not initialized and its value is undefined

var message = "H1"; JS supports direct initialization of variables

5. Data type: 5 kinds: Number string Boolean null undefined typeof used to detect type

6. (i) undefined: when declaring a variable with var without initializing it, the value is undefined (note: undefined is not initialized; The variable is not declared also produces undefined)

(b) null empty; If the defined variable is prepared to hold the object, the value of the variable can be set to NULL

(c) Boolean two literals: true false; (Note: case-sensitive) objects are used to convert non-logical values to logical values; the Boolean () function can return a Boolean value

Other data types are converted to Boolean rules: any non-null string, any object, not applicable, is true for any number other than 0 digits; The inverse is false;

(iv) Number type: Integer () and floating-point type (numeric value must contain a decimal point, and must have at least one digit after the decimal number; The floating-point value itself is an integer or no value after the decimal point, that is, to an integer)

(v) Nan is not a value: any operation involving Nan will return Nan, IsNan () to determine if it is not a numeric value

(vi) Numeric conversion: Number () parseint () parsefloat () These three functions can convert a non-numeric value to a numeric value

Several cases of value: (1) Boolean return: True 1, False 2; (2) numeric value, simple incoming or returning; (3) null returns 0; (4) undefined returns Nan

(5) String: When the string contains only numbers, the leading 0 is ignored, converted to decimal values, and when the string contains a valid floating-point format, leading 0 is ignored, converted to the corresponding floating-point value, when the string is empty, contains no characters, the conversion to 0, when the string contains characters other than the above format, Convert to Nan, and convert to decimal value of the same size when the string contains a valid hexadecimal format;

(6) Object: Invokes the ValueOf () method of the object, transforms the returned value according to the above rule, and if the conversion returns a value of Nan, call the ToString () method, and again follow the previous rule to convert the returned string value

(vii) String type: A sequence of characters consisting of 0 or more 16-bit Unicode characters, that is, a string (note: A string can be represented by double quotation marks (") or single quotation marks ('), but a string that begins with double quotation marks must also end with a double quotation mark, and a string that begins with a single quotation mark.

(1) string literal: \ n line break

\ t watchmaking

\b Spaces

\ r Enter

\f Paper Feed

\ \ Slash

\ ' single quotation mark ('), used in a string expressed in single quotation marks. For example: ' He said, \ ' hey.\ '

\ "Double quotation mark ("), used in a string expressed in double quotation marks. For example: "He said, \" Hey.\ ""

\xnn a character (where n is 0~f) expressed in hexadecimal code NN. For example, \x41 represents "A"

\UNNNN A Unicode character (where n is 0~f) expressed in hexadecimal code nnnn. For example, \U03A3 represents the Greek character σ

(2) Character of string: JS string is immutable, once the string is created, their value cannot be changed. To change the string saved by a variable, first destroy the original string, and then populate the variable with another string containing the new value

(3) Two ways to convert a value to a string: the ToString () value, the Boolean value, the object, and the string value all have this method, but undefined, NULL does not have this method

String () can also use a transformation letter without knowing whether the value to be converted is null or undefined

(eight) Object: constructor, normal function:

Object () Parameter: value objects of the corresponding type will be returned based on the data type of the parameter; The return value of object (): Returns an object of the type corresponding to the given value. The object wraps the given parameter.

7. Operator: (1) unary operator: operator with only one value (increment or decrement)

(2) Unary plus operator, unary minus operator

(3) Boolean operators: && and; | | or;! Non -

(4) Multiplicative operators: multiplication, division and modulus; additive operators: addition and subtraction

(5) Relationship Operation Fu Xiao (<), greater than (>), less than or equal (<=) and greater than or equal (>=)

(6) equal operator: = = equal;! = unequal; = = = congruent;!== not congruent

(7) Assignment operator: Multiply/Assign value (*=);

Addition/Assignment (/=);

Modulus/Assignment (%=);

Add/Assign value (+ =);

Subtract/assign value (? =);

Left Shift/Assignment (<<=);

Signed Right Shift/Assignment (>>=);

Unsigned Right Shift/assignment (>>>=)

8. Statement: (1) If statement: Used for logical Judgment (2) for statement; Has the ability to initialize variables and define the code to execute after the loop is executed.

9. Function: The function in JS is declared by using the functions keyword, followed by a set of parameters and function body, can encapsulate any number of statements through a function, and can call execution anywhere and at any time.

10. Understanding Parameters: JS's function does not mind passing in the number of parameters, also do not care about what data type is passed in the parameter. Even if you define a function that only receives two parameters, it is not necessarily necessary to pass two arguments when calling this function. You can pass one, three, or even no arguments; the parameters in JS are represented internally by an array, and in the body of the function you can access the array of arguments through the arguments object to get each parameter passed to the function. The arguments object is just like an array (it is not an instance of an array), you can access each of its elements through square brackets, and by accessing the length property of the arguments object, you can tell how many arguments are passed to the function.

The fourth chapter: the execution environment and the scope memory problem (limited capacity, the execution environment and the scope of the section skipped, in the future can be more understanding, and then Add. )

A variable of 1.js is loosely typed, and it is simply a name that is used to hold a particular value at a specific time; instead of the value of what data type must be saved when defining a variable, the value of the variable and its data type can change over the lifetime of the script.

2. Values for base and reference types: primitive type values refer to simple data segments, whereas reference type values refer to objects that may consist of multiple values.

(1) Basic data type: Undefined, Null, Boolean, number, and String

(2) The value of a reference type: (object) is an object stored in memory (JS does not allow direct access to the in-memory location, that is, the memory space of the object cannot be directly manipulated; When manipulating an object, it is actually manipulating the object's reference rather than the actual object.) To do this, the value of the reference type is accessed by reference)

(3) Dynamic properties: Basic types, dynamic properties created, non-impact, reference types, dynamic property modifications created, interaction

(4) Stored variables: Basic types, the existence of variables, each of which is not affected; The reference type's point is one, and the modification affects

(5) Pass parameter: Pass by the basic type whether the value or the object, will not change, by the reference type, its value will be changed

(6) TypeOf: Detects if a variable is a basic data type; instanceof determines if it is a reference type.

JavaScript Advanced Programming (summary in the book)

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.