js basic data types and the operator that

JavaScript basic data types:
numeric type (Number): integer and floating point into
an integer: 123 Float: 1.2 2.2
string type (String)
double or single quotes to cause the value of
Boolean type (boolean) : true (true) false (false)
undefined type: undefined designed to determine a variable has been created but no initial value;
empty type (null): used to indicate that a variable is empty (that the variable has been assigned but Fu is empty);
object type (Object): array, date and other objects
plus two functions +
1. when both sides plus a numeric value, an addition operation is performed
2. when the plus side where when the string is spliced

basic type conversion:
1. the value into a string (toString ())
Note point:
format: numerical variable name .toString ()
2. converts a string to an integer. (ParseInt ())
Note points:
1. The first character, if not only for the digital value will be reported Not A Number The NAN
2. Format: (parseInt (string variable names))
3. Convert the string to float point type. (ParseFloat ())
Note point:
Format: parseFloat (value of variable names)

 
 
 
Examples operator
Look at the following piece of JavaScript code.
c = a + b;

 

Wherein "=" and "+" are the operator.
JavaScript, there are many such operators, such as addition and subtraction, multiplication and division in JavaScript is relatively few basic operators, their meaning and there is no difference in mathematics.
JavaScript is the most common operator is the assignment operator "=", the one we have already emphasized, it is not equal.
Operator precedence
We all know that, in mathematics, "a + b * c" in this formula, the punishment will precede the addition. Also, in JavaScript, this formula will be executed in the same order. We call it the "priority" or "*" takes precedence over "+."
As with mathematics, change the order of operations is to add parentheses, JavaScript change in priority method is to add parentheses. E.g:
(a +b) * c

 

Connection string
In JavaScript, "+" denotes an adding unknown, also can use it to connect two strings, for example:
example = "black" + "turtle";

 

In the above example, example comprising a "turtle" string. This is due to the "+" to complete the "black" and "tortoise" connection, of course, you can also understand this behavior to a string of addition.
Since plus one, minus one operator from
Here we look at two very commonly used operators, since a plus "+"; from a minus "-." First look at an example:
5 = A;
A ++; // a value becomes. 6
A - // a values are changed back 5

 

In the above example, a ++ makes the value of a 1 increase in the basis of the original, a-- it now so that a basis in the minus 1. So, in fact, "a ++" can also be written as
"A = a + 1"; // equivalent to a ++

 

Composite Operators
Continuation of the above example, in fact, "a = a + 1" can be written as:
a + = 1; // re-assign a value after the addition of a 1

 

Thus the calculation and assignment operator coupled to comply with the called operator. Above we see is a combination of addition and assignment, JavaScript also in line with other operators:
a += b;// a = a + b
a -= b;// a = a - b
a *= b;// a = a * b
a /= b;// a = a / b

Guess you like

Origin www.cnblogs.com/wuqiance/p/11350548.html