1:javascirpt are strictly case-sensitive.
2:javascript (identifier) naming rules: The first character must be a letter, underscore, dollar sign, and other characters can be letters, underscores, dollar signs, or numbers
The 3:ecmascript identifier is in hump case format, which is the first lowercase letter, and the first letter of each word is capitalized. (but no one is obligated to require this format)
4:
Single-line Comment
/*
* This is a multiline comment
*/
5: Each statement is best to end with a semicolon, but you can also omit the semicolon.
6:
if (test)
alert (test); Effective but error-prone, preferably not used
if (test) {
alert (test);//Recommended Use
}
7:var obj; A variable like this that has not been initialized will hold a special value undefined
8:obj=100 This is valid, but not recommended, which is equivalent to declaring a global variable
9:ecmascript has 5 simple data types: Undefined,null,boolean,number and string
1 complex data types of object
10:typeof operator
var message = ' message ';
typeof message
typeof (Message)
The 11:undefined type has only one value, which is the special undefined
12:
VAR message;
Alert (message)//undefined
alert (age);//Error
13: It is best to display the initialization variables, so that when the typeof operator returns the undefined value, we know that the variable being detected is not declared, not yet initialized
Because a variable without a declaration is returned directly with the typeof operator undefined
14 to convert a value to its corresponding Boolean value, you can call the Transform function Boolean ()
15Number type: The first digit of the octal literal must be zero, and the last two digits of the hexadecimal literal must be the ox
Floating-point Lou can do this: var floatnum =. 1; But it is not recommended to use
If there is no number after the decimal point, the value can be saved as an integer value, as well, if the floating point itself represents an integer (for example, 1.0) then the values are also converted to integers
14:number.max_value the maximum value of an integer
Number.min_value the minimum value of an integer
If you calculate a value that exceeds the range of JavaScript values, the value is automatically converted to a special infinity, and if a positive or negative infinity value is returned, it will not continue to participate in the next calculation
To determine whether a value is poor, you can use the Isfinite () function
Access to number.negative_infinity and number.positive_infinity can get the value of positive and negative infinity, so the two properties are actually saved-infinity and infinity respectively.
15NaN Features: 1 Any operation involving Nan will return Nan,2nan not equal to any value, including Nan itself IsNaN () This function takes a parameter that can be any type, and this function will help us determine if the parameter is "not a value"
16parseInt capable of various integer formats
Number (789)//cannot convert 789Yun
parseint ("789Yun");
parseint ("0xa313", 16);//cardinality setting can also convert octal
parseint (""); NaN
Parsefloat only parses a decimal value, so it does not specify the usage of cardinality with the second argument
Parsefloat parses a string if the string contains a number that can be resolved to an integer (no decimal point or all 0 after the decimal point) parsefloat () returns an integer
Parsefloat ("32.32")
17 The string represented by double quotation marks is exactly the same as the string in single quotation marks, and any string length can be obtained by its length property.
Convert to String Method tostring (), numeric, Boolean, object, and string are some methods, but null and undefined values do not have this method
ToString () can also pass cardinality eg:var a = 123 if it is a numeric call; A.tostring (16);
When you do not know the value null or the undefined value, you can use the Transform function string (), which converts any type of value to a string, and the string () function follows the conversion rule: 1 If the value has the ToString () method, The method (without parameters) is called to return the corresponding result 2 if the value is NULL returns "NULL" 3 if the value is undefined returns "undefined"
The object in 18ECMAScript is actually a set of data and functions. In ECMAScript, if you cannot construct a function to pass parameters, you can omit the pair of parentheses that follow.
As shown below
var obj = new Object ();
var obj = new Object;
Each instance of 19Object has the following properties and methods
Constructor holds the function for creating the current object
hasOwnProperty (PropertyName) is used to check whether a given property exists in the current object instance (not in the instance's prototype)
isPrototypeOf (object) is used to check if an incoming object is a prototype of another object
propertyIsEnumerable (PropertyName) is used to check whether a given property can use the For-in statement
20with statement:
With (location) {
var qs = search.substring (1);
var hostName = HostName;
var url = href;
}
21switch
var num = 25;
Switch (TRUE) {
Case Num < 0:alert (' less than 0 '); Break
Case num >= 0 && num <= 10:alert (' between 0 and 10 '); Break
Case num > && num <= 20:alert (' between and 20 '); Break
Default:alert (' More than 20 ');
}
The switch statement uses the congruent operator when comparing values, so type conversions do not occur
Any code after the return statement in the 22 function will never execute
The return statement can also have no return value, in which case the function will return a undefined value after it has stopped executing
23 The Length property of the arguments object allows you to get the number of arguments passed to the function, the named argument without passing the value is automatically assigned the undefined value (all parameters in the ECMAScript pass the value, it is not possible to pass the argument by reference)
24ECMAScript function is not overloaded
25 Unlike other languages, ECMAScript does not define separate data types for integer and floating-point values, and Numer types can be used to represent all values
There is no need to specify the return value of a function in 26ECMAScript because any ECMAScript function can return any value at any time
A function parameter in a 27ECMAScript function is passed in the form of an array containing 0 or more values.
28 You can pass any number of arguments to the ECMAScript function, and you can access these parameters by arguments objects
Basic JavaScript Concepts