Expressions and operators
An expression
An expression can ask for a value, and the evaluation can contain an operation.
var
length=80
Two or more values can be used in an expression, and the expression eventually returns a value. If you ask for the area of the table.
var area=80*60
Operator
An operator is required in the expression, which operates on one or more values and gets a value.
Commonly used operators are: assignment operators, comparison operators, arithmetic operators, logical operators, string operators.
Arithmetic operators
Arithmetic operators are similar to mathematics, and are used very much in numerical calculations.
Add + adds a value and another value
Subtraction-Subtracts one value from another
Divide/Divide two values
Multiply * multiply two values by using an asterisk (*)
Increment + + Current value plus one
Decrement--current value minus one
Modulo% two values divide, return remainder
String operator
There is only one string operator (+) that is used to concatenate strings sequentially.
var
strA=
"Hello"
;
var
strB=
"JavaScript"
;
var
strC=strA+strB;
document.write(strC);
strings can not only concatenate strings, they can also concatenate numbers, and numbers are used when strings are concatenated.
var
strA=
"Hello "
;
var
strB=368;
var
strC=strA+strB;
document.write(strC);
Javascript&jquery. Expressions and operators