Grammar
- Strict mode enables strict mode to add "use strict" above the top of the script or inside the function; Statement.
Data type
- typeof
typeof returns a undifined,boolean,number,string,object,function of six strings, typeof null returns "Object".
- There are six types of data: Undefined,null,boolean,number,string,object
- Undefined
- Null
Although null is equal to undefined, it is used differently. A variable that holds an object is not assigned, and the variable should be saved to null.
- Boolean
Data type |
The value converted to true |
Value converted to False |
Boolean |
True |
False |
String |
Any non-empty string |
"" (empty string) |
Number |
Any non-0 numeric value (including infinity) |
0 and Nan |
Object |
Any object |
Null |
Undefined |
Without any circumstances |
Undefined |
- Number
Octal notation: The number is added in front of 0, and octal is not valid in strict mode.
Hexadecimal means: 0x before the number.
Infinity and-infinity represent positive and negative infinity.
NaN (non-numeric) is not equal to any number.
- String
\ n |
line wrapping |
\ t |
tabulation |
\b |
spaces |
\ r |
carriage return |
\f |
feed |
\ \ |
slash |
\ ' |
single quote |
\ " |
double quotes |
\xnn |
one character in hexadecimal nn (where n is 0~f). For example \x41 Represents a |
\unnnn |
A Unicode character (where n is 0~f) represented in hexadecimal nnnn. For example, \u03a3 means the Greek character σ |
the
toString () method, which can pass in the cardinality of a parameter, such as binary, num.tostring (2);
If you do not know if the value to be converted is null or undefined, you can use the string () function, if the value is not null or undefined call the ToString () method, NULL returns "NULL", Undefined returns " Undefined ";
To convert a value to a string, you can use the + "" method;
- Object
Common property methods for object instances
Constructor |
Holds the function that is used to create the current object. such as Object () |
hasOwnProperty (PropertyName) |
Used to check whether a given property exists in the current object instance (rather than in the prototype of the instance), PropertyName must be specified as a string. such as O.hasownproperty ("name") |
Ispropertyof (Object) |
Used to check if an incoming object is a prototype of another object |
propertyIsEnumerable (PropertyName) |
Used to check if the For-in statement can be used to enumerate, PropertyName must be specified as a string. |
Tolocalstring () |
Returns the string object of the object |
ToString () |
Returns the string object of the object |
ValueOf () |
Returns the string, numeric, or Boolean representation of the object, usually the same as the ToString () value |
Operator
- When a unary plus operator is applied to a non-numeric value, the operand converts the value like the number () transformation function.
- Bitwise non-intrinsic: negative value minus 1 for operand
- Logic and (&&) operators:
Returns the second operand if the first is an object
If the second is an object, the object is returned only if the first operand is true
Two operands are objects, returns the second operand
There is an operand that is NULL to return NULL
There is one operand that Nan returns nan
There is an operand that is undefined returned undefined
- Logic or (| |) Operator
Returns the first operand if the first operand is an object
Returns the second operand if the evaluation result of the first operand is false
If two operands are objects, the first operand is returned
Returns NULL if all two operands are null
If two operands are Nan, a nan is returned
If two operands are undefined, the undefined is returned
Use logic or this behavior to avoid assigning null or undefined values to variables, such as: var myObject = Prrfferredobject | | Backupobject
Code and notes git address: [Email protected]:mid__summer/pjwd.git
Reading "JavaScript advanced Programming" Note one-basic concepts