Introduction: The core of any language is bound to describe the most basic work of the language, and the description of the content usually involves the syntax of the language, operators, data types, built-in functions and other basic concepts used to build complex solutions. Today I began to summarize these basic concepts, because some of the content is too basic I do not repeat (this summary does not apply to the small partner who did not learn JS), and the basic concept of the content is also very long, the length of the space is also a little bit, even the next space may continue to be this content, But I will do my best to summarize the content of the streamlined, better records presented.
Case Sensitivity and keywords:
To understand that the first concept is that everything in ECMAScript (variables, function names, and operators) is case-sensitive, for example: test is not the same as test, and you must be careful not to use keywords (javascript keywords) when naming.
Identifier:
An identifier is the name of a variable, function, property, or parameter of a function. The rule is that the first character must be a character, an underscore, or a dollar sign ($), while the other characters can be letters, underscores, dollar signs, or numbers. By convention, the ECMAScript identifier is in hump-case format, which is the first letter, lowercase, and the second upper case (myTest). Although this is not mandatory, but for the sake of the beautiful code, I personally would rather recommend this way.
Strict mode:
ECMAScript 5 introduces the concept of strict mode (strict model). As the name implies, strict mode is to define a different parsing and execution model for JavaScript (more normative, rigorous). In this mode, some of the indeterminate behavior in ECMAScript 3 will be handled. Here I do not repeat, the details can see the previous link, and the following summary I also encountered the strict mode of the various situations discussed. Then the way to enter strict mode is to enable strict mode in the entire script, you can add "use strict" at the top. The function takes strict mode:
function A () {
"Use strict";
------Function Body---
}
Keywords and reserved words:
Keywords and reserved words (click to view)
variable with no VAR declaration:
For example: function A () {
Message= "HI"; (not declared with Var, it becomes a global variable).
}
Test ();
Aler (message); Hi
This omits the Var, the message becomes the global variable, as long as the call test (), can be anywhere outside the function can access the variable but this is not recommended, because: 1, the local scope of all variables defined is difficult to maintain. 2, if deliberately ignore the var operator, also because the corresponding variable will not be immediately defined and cause unnecessary confusion, undeclared variable assignment in strict mode throws Referenceerror (reference error, the object indicates that a non-existent variable is referenced. Error (The following summary will talk about the variables and functions of JavaScript before executing a "variable/function promotion").
Data type:
There is a simple data type in ECMAScript: Undefined, Null, Boolean, number, String.
typeof operator:
This is a frequently used operator whose purpose is to detect the data type of a given variable. Sometimes the typeof operator returns some confusing, but technically correct values, such as (typeof null), return an object because null is an empty reference object. Safari 5 and previous versions, Chrome 7 and previous versions will return function to the regular expression. In this case, the other browser returns object.
The difference between Undefined and null:
Because sometimes we encounter (null = = undefined result is true), this time someone will think that these two are equivalent relationships, but in essence, the concept is different, if you use (null = = = undefined return false), you can see, The types of the two are different. Null is an object, and it is better to initialize the variable to null instead of the other value if the defined variable is prepared for future use in saving the object. In fact, we can see different from the literal roadbed, undefined more can refer to a variable declaration but not defined. And null is an object that is empty (the pointer is empty) so that, in fact, they are clearly distinguishable.
-----------------------------------------------------------------------------------
After this chapter, the next chapter continues to summarize the concepts of basic grammar, data type, and so on.
(In this chapter, my summary is biased on the basis, but also have a lot of knowledge points I used a link, such as "reserved word.") Keyword "there. Not to say that these points of knowledge is not important, but indeed its knowledge points too much, I can not write it is not better than others summed up, but also may be confusing the layout to make the reading experience unpleasant. So I want to read the small partners, or should be a click on the link to see, in their own knowledge points to comb. The summary of this piece of knowledge is still more, there are some I really can not be objective cognition, that is what I should summarize into what form, so can only according to their own thought to summarize. After that, I'll make more changes to what I've written. After all, people are also in continuous progress, and hope to write their own blog, so that their own learning at the same time, but also to see my blog people look happy some).
"JavaScript Advanced Programming" Learning Summary three (1)