Page 94 - DCAP202_Fundamentals of Web Programming
P. 94
Unit 7: Operators in JavaScript
7.4 Keywords Notes
Arithmetic Operators: function as the addition, subtraction, multiplication, division, and modulus
operators, and operate very similarly to other languages.
Assignment Operators: assigns a value to a variable.
Bitwise Operators: are kept for parity with the related programming languages but are unlikely
to be used in most JavaScript programs.
Conditional Expressions: can have one of two values based on a condition.
Increment Operators: may be applied before or after a variable. When they are applied before a
variable they are pre-increment operators, and when they are applied after a variable they are
post-increment operators.
Operator: An operator is a symbol (it can also be a word) that performs calculations, comparisons
or assignment on one or more values.
Precedence of operators: The precedence of operators determines the order they are applied
when evaluating an expression.
Typeof: The typeof is a unary operator that is placed before its single operand, which can be of any
type.
7.5 Review Questions
1. What is operator? Discuss with example.
2. Differentiate between arithmetic and bitwise operators.
3. Why comparison operators are used?
4. Describe logical operators with the help of example.
5. What is === operator?
6. What does the delete operator do?
7. What is function of Boolean operators in JavaScript?
8. Evaluate “1”+2+4.
9. Solve 2+5+”8".
10. What do you mean by expression in JavaScript?
Answers: Self Assessment
1. Comparison 2. ~
3. *= 4. Reduces
5. Conditional 6. Typeof
7. precedence 8. !=
9. increment 10. Bitwise OR
11. expression 12. null value
LOVELY PROFESSIONAL UNIVERSITY 87