Introduction to JavaScript (2)

Increment and decrement operators work on any value, and the difference between prepend and postpend is the same as in C

All values ​​are stored in IEEE-754 64-bit format, and bitwise operators do not directly operate on 64-bit values. Instead, convert the 64-bit value to a 32-bit integer, perform the operation, and finally convert the result back to 64-bit. When applying bit operations to the special NaN and Infinity values, both values ​​are treated as 0.

When there is an operand that is not a boolean value, the logical AND operation and the logical OR operation do not necessarily return a boolean value. Both are short-circuit operations. You can use the behavior of logical OR to avoid assigning null or undefined values ​​to variables.

The two operators, equality and inequality, will first convert the operands and then compare their equality, null == undefined will return true, if both operands are objects, compare whether they are the same object

The two operators, congruent and not congruent, do not convert the operands before the comparison, and it is recommended to use the congruent and not congruent operators

Flow control statements include if statement, do-while statement, while statement, for statement, for-in statement, label statement, break statement, continue statement, switch statement

The role of the with statement is to set the scope of the code to a specific object, mainly to simplify the work of writing the same object multiple times, but it is not recommended to use

A function is declared with the function keyword, followed by a set of parameters and the function body. It is not necessary to specify whether to return a value or not. The recommended practice is to either let the function always return a value or never return a value, otherwise it will bring inconvenience to debugging

In the function body, you can access this parameter array through the arguments object, and all parameters are passed by value

Functions cannot be overloaded in the traditional sense

 

Variables may contain values ​​of two different data types. Primitive values ​​refer to simple data segments, while reference values ​​are objects that are stored in memory, to which properties and methods can be added, and properties and methods can be changed and deleted. method

When copying a value of reference type from one variable to another, both variables will actually refer to the same object

Using the instanceof operator, returns true if the variable is an instance of the given reference type

An execution environment defines other data that a variable or function has access to. Each execution environment has a variable object associated with it. All variables and functions defined in the environment are stored in this object, although the code we write cannot access it. This object, but the parser uses it behind the scenes when processing the data

The global execution environment is considered to be the window object. The inner environment can access all outer environments through the scope chain, but the outer environment cannot access any variables and functions in the inner environment. Variables declared with var are automatically added to the closest environment middle

JavaScript does not have block scope

The best way to optimize the memory footprint is to keep only the necessary data for the executing code, and once the data is no longer useful, it is best to release its reference by setting its value to null

 

An object is an instance of a specific reference type, and new objects are created using the new operator followed by a constructor

Object literal notation can also be used to create Object instances, which simplifies the process of creating objects with a large number of properties, and is preferred by developers and the preferred way to pass a large number of optional parameters to functions

Use square bracket notation to access object properties, the main advantage of this is that properties can be accessed through variables

Each item of the array can hold any type of data. The length property of the array is not read-only. By setting this property, you can remove items from the end of the array or add new items to the array.

The Array.isArray() method finally determines whether a value is an array or not. Arrays have stack methods push() and pop(), queue methods shift() and unshift(), reordering methods sort() and reverse(), and There are concat(), slice(), splice(), indexOf(), lastIndexOf() methods

Array iteration methods include every(), filter(), forEach(), map(), some(), and merge methods include reduce(), reduceRight()

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325058808&siteId=291194637