In this post I cleared your all conecpt in javascript. I writing a post about what rules and operations in javascript?
The fourth part of the study subjects Javascript is basic arithmetic in JavaScript. With this basic arithmetic operations can be combined or changed data in the Javascript code. There are many operations (also known as operator) is used in Javascript.Arithmetic: The arithmetic Very common and common, the operations of multiplication and division except that any student who knows. The variable and its value is the number.
= (equal sign) - ie, (x = 8)Besides the simple math on it also uses the following arithmetic for programming.
+ (plus sign) - ie, (x = 7 +8)
- (minus) - ie, (x = 7-8)
* (multiplication) - ie, (x = 7 * 8)
/ (Breaks) - ie, (x = 7/8)
Modulo ( % ) - Do not be mistaken with a percent sign, here is balance calculations take the division. Consider the following example shows the remainder of the division is 2 3 8 for example: 8% 3 result 2 10% 2 result 0
Increment ( + + ) - This operation adds an extra base value units. Often used as an abbreviation allowed in programming. For example, if we have the variable 'i' we can increase the variable i add a unit by writing i + + instead of to i = i +1 . , for example: x = 7, x + +, the result is x = 8
Decrement ( - ) - Subtract the original value of 1 unit. If we have variable 'i' can be used to write i - instead of i = i-1 . Example: x = 7, x -, the result is x = 6
Assignments
Assignments are one of the basic operations of JavaScript. Assignments used to assign a value to a variable. In the assignment expression, the right operand is assigned the value of the operand to the left of the equal sign (=)Operator | Example | Same as |
= | x = y | x = y |
+ = | x + = y | x = x + y |
- = | x - y = | x = xy |
* = | x * = y | x = x * y |
/ = | x / = y | x = x / y |
% = | x% = y | x = x% y |
Comparison Operands
A mathematical comparison returns a boolean value is TRUE (true) or FALSE (false). By comparing the two operands mark comparison (==) Javascript will give us the answer depends on the value of the operand. View the table below to understand math betterOperator | Meaning | Example |
== | Identical | 3 8 result == FALSE |
! = | Different | 3! = 8 result TRUE |
> | Bigger | 3> 8 result FALSE |
< | Smaller | 3 <8 result TRUE |
> = | Bigger or identical | 3> = 8 result FALSE |
<= | Smaller or identical | 3 <= 8 result TRUE |
Logical operations (booleans)
A mathematical logic compares two expressions and returns a value of TRUE (true) or FALSE (false).&& - AND - AND operator compares two expressions and returns TRUE if both values are true and vice versa will return FALSE.
x = 5
y = 8
x <7 && y> 3
(returns TRUE)
| | - OR - OR operation compares two expressions and returns TRUE if either the right and vice versa returns FALSE.
x = 5
y = 8
x> 7 | | y <3
(returns FALSE)
! - NOT - NOT A mathematical, math negative returns TRUE if the expression is false, and vice versa if true, the expression returns FALSE.
x = 5
y = 8
! (x == y)
(returns TRUE because 'x' other 'y')
Operands used for string (The last rule)
Addition operation is used to combine two variables with text values together t1 = "Have a good" t2 = "life." t3 = t1 + t2 (return value of the variable t3 is "Have a good life.")loading...
loading...
Post a Comment