JavaScript is designed and implemented in accordance with the ECMAScript standard. The JavaScript syntax mentioned later is actually implemented in ES5 standard. JavaScript is designed and implemented in accordance with the ECMAScript standard. The JavaScript syntax mentioned later is actually implemented in ES5 standard.
What are the basic syntaxes?
What are the most basic syntaxes?
The basic syntax is similar to that of almost all languages. It is nothing more than data types, operators, control statements, and functions.
5 Basic Data Types & 1 complex data type
JavaScript contains five basic data types: undefined/null/boolean/number/string. The basic data types are five. There are no other types!
JavaScript contains one complex data type, namely the Object type, which is the base class of all other objects.
Note: JavaScript does not distinguish between floating-point numbers and integers, which are expressed by number.
The five basic data types mentioned above and one complex data type here are all the data types!
Basic Operators
This is common sense, just know what's going on.
Common operators include Arithmetic Operators, Relational operators, boolean operators, and value assignment operators.
Control statement
This is the control statement we often call such as if-else.
Not many are commonly used: if statements, switch statements, for statements, while statements, and for-in statements.
Function
A function is a small logical encapsulation. In theory, the more independent the logic, the better.
JavaScript Functions are quite different from other languages. JavaScript functions can be used as parameters or return values.
In addition, JavaScript Functions can accept any number of parameters and can access these parameters through the arguments object.
The basic syntax of any language is the same. Apart from some differences in details, it is basically the above: data types, operators, control statements, functions, modules, and so on.
Next we will introduce some more complex concepts.
Variable, scope, memory problems
Variable
JavaScript variables are classified into two types: basic type and reference type. The basic type is the five basic data types mentioned above, and the reference type is the Object mentioned above and other complex data types based on it.
Basic memory type: it occupies the actual size of the memory. When assigned, a new copy is created in the memory. Stored in stack memory.
Struct reference type: pointer to the object rather than the object itself. When assigning values, you only create a new pointer to the object. Stored in heap memory.
If you are a newbie, we suggest you go to ES6 + Babel.
For more information about how to sort out related articles on JavaScript knowledge, refer to the PHP Chinese website!