Basic syntax, type, variable
Methods of judging Non-numeric values: (Because infinity and nan they are not equal to any value, including themselves)
1, x!= x, return True when X is Nan;
2, with isNaN (x), when x is Nan or non-numeric value, returns true;
3, with isfinity (x), when x is not Nan, Infinity,-infinity return true;
Although (strings, numbers, Boolean values) are not objects, their properties are read-only, but they can also refer to their properties and methods as if they were manipulating objects:
JavaScript constructs a temporary object (called a wrapper object) of a (String, number, Boolean), and then invokes its properties and methods through this temporary object, which changes only the temporary object, and then the temporary object is destroyed. The changes made do not affect the original data;
You can explicitly construct a wrapper object whose value is equal to the original data ' = = ', but the type is different ' = = '
Number a spin string:
A.tostring (n)//n representation
A.tofixed (i) a.toexponential (i) a.toprecision (j)//i to decimal digits, J to show number of digits
string s to decimal digits: (ignoring the preceding spaces, converting as many digits as possible, ignoring the non-numeric content that follows, where ' 0X ', ' 0x ' starts with a 16-digit conversion)
parseint (S,[n])//n represents the system, optional parameters, the s in the N-ary number to decimal number
Parsefloat (S,[n])
Object Auto-spin string step:
1. If there is a ToString () method, and it can return the original value, call it, will return the original value of the string;
2. If the first step is invalid, call valueof (), the original value returned to the string;
3. The first two are not valid, then throw the type error exception;
Object Automatic Digital Step:
1. If there is a valueof (), call it and return the original value to the number, which can be returned;
2. If 1 is invalid, try calling ToString () to turn the original value returned to the number and return the number;
3. If 1, 2 are invalid, then throw type error exception;
The Date object is an exception
Variable declaration advance:
Calling an undeclared variable, the compiler puts the declaration part of the variable ahead of it and leaves the initialization part in place;
(repeated declared variables, local will overwrite external)
var s1 = ' ggggg ';
function f () {
console.log (S1);//s1 = = undefined
var s1 = ' CCCCCC ';
Console.log (S1); S1 = = ' CCCCCC '
}
Bit Operation:& | ^ ~
And: Bitwise AND, to the left and right two integer operands to perform and operations, only when the corresponding bit is 1 o'clock, the result is 1;
|: bitwise OR, the corresponding bit has a 1, then the result is 1;
^: Bitwise XOR, corresponding bit is 0, not the same as 1;
~: Bitwise counter, unary operator, all bits reversed, equivalent to changing the symbol and minus 1;
(n is between 0~31)
<<n: All bits left n bit, the value is multiplied by 2 n times, discard the leftmost n position, add the right n bit with 0来;
>>n: All bits are shifted to the right n bit, ignoring the right overflow bit, filling the left bit with the original operand decision, the result is equal to 2 n times, discard the remainder, 7>>1=3, -7>>1=-4
<<<n: With <<, just fill the left bit with 0来.
The comparison size between strings:
A JavaScript string is a series of 16-bit integer values that compare the values of their characters with the numeric values of the uppercase and lowercase characters.
Comparison operators prefer numbers, as long as there is a number of operands, do numeric operations, only when two are strings, do string comparisons
The ' + ' operator prefers strings, as long as one operand is a string, the string concatenation operation is done
X in P
Check for attribute x in object p, including method
A instanceof A
Check if object A is an instance of Class A, including detection of its parent class
False values: false, null, undefined, 0,-0, NaN ""
Truth value: In addition to the above values, the other values are truth;
Objects: Other values are objects except strings, numbers, true, false, NULL, and undefined!
The above is a small series for everyone to bring the JavaScript learning notes _ talking about the basic grammar, types, variables, all the contents of the hope for everyone to help, a lot of support cloud Habitat Community ~