13 Time bought the "advanced Programming of JavaScript" (3rd edition) and jquery book, usually occasionally also look at one or two eyes, no system to see, this year set the goal is to learn the web, so intend to learn a system. Write down the JavaScript series blog is also a note, good review later. The content is summarized in the order of the JavaScript Advanced Programming (3rd Edition), which summarizes some of the basic concepts of JavaScript today.
1. Case sensitivity (This does not have to be explained)
2. Naming rules
Generally with letters, numbers, underscores, or dollar $ sign. The first character must be a letter, an underscore, or a dollar sign $.
3. Statements
You can omit the semicolon at the end of the statement, but in order to make the encoding easy to read, reduce the error and try adding semicolons.
4. Variables
Variables are loosely typed and can hold any type of data. Declare variables to be declared with Var as much as possible, otherwise the variables will become global variables. It is also not possible to define a variable named eval and arguments, which would result in a syntax error.
5. Data type
It consists of 5 basic data types: Undefined, Null, Boolean, number, and string. There is also a complex data type: Object.
1). Undefined type
There is only one value undefined, and when you declare a variable with VAR but do not initialize it, the value of the variable is undefined. That is, the default value of the defined variable is undefined.
2). Null type
It also has a value of NULL, which represents an empty object pointer, and if the variable is used to hold the object, it is best to initialize the variable to null. This allows you to determine whether a variable is a reference to a saved object, as long as the variable is a null value.
3). Boolean type
This slightly.
4). Number Type
There are two main things here: Nan and numeric conversions.
1.NaN: A non-numeric value indicating that the operand of the numeric value returned does not return a numeric value. Like X/0=nan.
It has two main places that are more special: 1. Any operation involving Nan returns Nan. 2.Nan is not equal to any value, including Nan. How do you tell if a value is a non-value? Here is a function isNaN (), passing in an argument of any type, and returning true if it cannot be converted to a numeric value.
2. Numeric conversions
There are 3 main functions: Number (), parseint (), parsefloat (). The latter two are mainly used to turn a string into a numeric value.
Number () Conversion rule:
If it is a Boolean value, Ture becomes 1,false 0;
If it is a number, simply pass in the outgoing;
If NULL, returns 0;
If it is undefined, return nan;
If it is a string:
1. Contains only numbers (including the front with a plus sign, minus): to 10 decimal, the preceding 0 is removed such as: "011" into 11;
2. Include a valid floating-point number and a floating-point number
3. Valid hexadecimal to equal-size decimal
4. The string is empty and converted to 0
5. If a string other than the above format is included, it is converted to Nan
6. If it is an object, call the object's valueof (), convert the returned value according to the preceding rule, or, if the conversion result is Nan, call the object's ToString (), and then follow the previous rules to convert.
5). String type
The string is immutable, and once created, the value does not change. To change first destroy the original string and then populate it with the new variable.
String conversions are commonly used in two ways: ToString (), string (). But null, undefined not.
Values, Booleans, and strings have the ToString () method. Most cases do not need to pass parameters, and when the ToString () method of a value is called, a parameter can be passed: the cardinality of the output value, which is 10 by default.
6). Object type
objects can be created with the new operator, and you can customize objects for them by adding properties and methods.
Each instance of object has the following properties and methods:
Constructor: Holds the function that is used to create the current object. constructor function.
hasOwnProperty (PropertyName): Used to check whether a given property exists in the current object instance (not in the instance's prototype). The property name as a parameter must be specified as a string.
isPrototypeOf (object): Used to check if an incoming object is a prototype of another object.
propertyIsEnumerable (PropertyName): Used to check whether a given property can be enumerated using the For-in statement. You also specify the parameters with a string.
Toloaclestring (): Returns the string representation of the object.
ToString (): Returns the string representation of the object.
valueof (): Returns the string, numeric, or Boolean representation of an object.
6.typeof operator
Because it is loosely typed, there is a need to have a method to detect the data type of a given variable typeof. Using the typeof operator on a value may return one of the following strings:
"Undefined": undefined
"Boolean": Boolean value
"String": String
"Number": Value
' Object ': Object or null
"Function": Functions
A basic concept of javascript