Home > Article > Web Front-end > JavaScript Learning (2) Summary of JavaScript Common Problems_Basic Knowledge
1. Methods and variables in JS are case-sensitive
2. There is no special difference between single quotes and double quotes in JS, and both can be used to create strings. But as a general rule, most developers prefer single quotes to double quotes, but the XHTML specification requires that all attribute values must be enclosed in double quotes. Using single quotes for JS and double quotes for XHTML makes it easier and clearer to mix code between the two.
Single quotes can contain double quotes, and similarly, double quotes can contain single quotes.
3. Brackets
First of all, it needs to be explained that brackets in JS contain two semantics, which can be delimiters or expressions.
a. Everyone is very familiar with the delimiter (1 3) * 3 equals 12
b. (function(){})(); The pair of brackets before function are used as delimiters, and the following brackets indicate that this will be executed immediately method.
4. Function calls and references
Because brackets represent execution, so:
var foo=example(); foo represents the return value of the function
var foo1=example; assign function reference Give a value foo1
5. Overloading
JS does not support overloading, so the overloading mentioned here is actually more similar to replacing
JS does not distinguish the number of parameters
6. Scope and closure
Scope refers to the code space that has access rights to a certain attribute or method. For example: