Skip to content

Latest commit

 

History

History
64 lines (31 loc) · 3.1 KB

File metadata and controls

64 lines (31 loc) · 3.1 KB

Java Script operators and Expressions.

Operators Types :

1. Assignment operators : An assignment operator assigns a value to its left operand based on the value of its right operand.

2. Comparison operators : A comparison operator compares its operands and returns a logical value based on whether the comparison is true. The operands can be numerical, string, logical, or object values.

3. Arithmetic operators :An arithmetic operator takes numerical values (either literals or variables) as their operands and returns a single numerical value.

4. Bitwise operators : A bitwise operator treats their operands as a set of 32 bits (zeros and ones), rather than as decimal, hexadecimal, or octal numbers.

5. Logical operators : Logical operators are typically used with Boolean (logical) values; when they are, they return a Boolean value.

6. String operators : In addition to the comparison operators, which can be used on string values, the concatenation operator (+) concatenates two string values together, returning another string that is the union of the two operand strings.

7. Conditional (ternary) operator : The conditional operator is the only JavaScript operator that takes three operands. The operator can have one of two values based on a condition. The syntax is: ### condition ? val1 : val2.

8. Comma operator : The comma operator (,) evaluates both of its operands and returns the value of the last operand. This operator is primarily used inside a for loop, to allow multiple variables to be updated each time through the loop.

9. Unary operators : A unary operation is an operation with only one operand , like delete , typeof , void .

10. Relational operators :A relational operator compares its operands and returns a Boolean value based on whether the comparison is true.

Operator precedence :

The precedence of operators determines the order they are applied when evaluating an expression. You can override operator precedence by using parentheses.

Expressions :

An expression is any valid unit of code that resolves to a value.

Every syntactically valid expression resolves to some value but conceptually, there are two types of expressions: with side effects (for example: those that assign value to a variable) and those that in some sense evaluate and therefore resolve to a value.

for more information about operators and Expressions visit JS OP AND EXP .

Loops .

Loops offer a quick and easy way to do something repeatedly. This chapter of the JavaScript Guide introduces the different iteration statements available to JavaScript.

The statements for loops provided in JS are :

1. for statement.

2. do...while statement.

3. labeled statement.

4. continue statement.

5. while statement.

6. break statement.

7. for...in statement.

8. for...of statement.

for more information about Loops visit LOOPS .

Relational operators