Web Designing MCQs

Top 20 MCQ On JavaScript Expressions And Operators

Pinterest LinkedIn Tumblr

This set of multiple-choice questions on JavaScript expression and operators includes MCQ on JavaScript expressions, equality, inequality, and comparison operators. It also includes logical, assignment, and evaluation expressions along with different types of operators; conditional, typeof, delete, void and comma used in JavaScript.

1. The ……………. operator is known as the equality operator, which checks whether its two operators are “equal” using a more relaxed definition of sameness that allows type conversion.
A) =
B) = =
C) = = =
D) All of the above

2. The ……………………. operator is known as strict equality operator, and it checks whether two operands are “identical” using a strict definition of sameness.
A) =
B) = =
C) = = =
D) All of the above

3. The …………………. returns false if two values are equal to each other according to = = and returns true otherwise.
A) !=
B) !
C) != =
D) All of the above

4. The …………….. operator returns false if two values are strictly equal to each other and returns true otherwise.
A) !=
B) !
C) != =
D) All of the above

5. If the two values do not have the same type; the ……………….. operator may still consider them equal.
A) = =
B) = = =
C) Both A and B
D) None of the above

6. State whether the following statements are True or False for equality operator(= =).
i) If one value is null and the other is undefined, they are equal.
ii) If one value is number and the other is a string, convert the string to a number and try to comparison again, using converted value.
A) True, False
B) True, True
C) False, True
D) False, False

7. State whether the following statements are True or False for strict equality operator(= = =).
i) If the two values have different types they are equal.
ii) If both values are null or both values are undefined, they are equal.
iii) If  both of the Boolean value are True or both of the Boolean value are False, they are equal.
A) i-True, ii-False, iii-True
B) i-False, ii-True, iii-True
C) i-True, ii-False, iii-False
D) i-False, ii-True, iii-False

8. The ……………….. operator evaluates to True if its first operand is less than its second operand; otherwise it evaluates to False.
A) <
B) >
C) <=
D) >=

9. The ………………. operator evaluates to True if its first operand is greater than or equal to its second operand; otherwise it evaluates to  False.
A) <
B) >
C) <=
D) >=

10. While using comparison operators, if after object to primitive conversion, at least one operand is not a string, both operands are converted to ………………
A) String
B) Boolean
C) Number
D) Object

11. If either operand is NaN or converts to NaN, then the comparison operator always returns …………
A) False
B) True
C) NaN
D) Undefined

12. If we compare 11 as a string and 3 as a number (“11″<3), what will be the result.
A) False
B) True
C) NaN
D) Undefined

13. If we compare “one” and 7 with less then comparison operator (“one”<7), what will be the result.
A) False
B) True
C) NaN
D) Undefined

14. The ………………. operator expects a left-side operand that is an object and right-side operand that identifies a class of objects.
A) comparison
B) in
C) instanceOf
D) logical

15. The ………………… operator expects a left-side operand that is or can be converted to a string.
A) comparison
B) in
C) instanceOf
D) logical

16. The …………….. operators perform Boolean algebra and are often used in conjunction with the  relational operators to combine two relational expressions into one more complex expression.
A) comparison
B) in
C) instanceOf
D) logical

17. If var O={x:1, y:2}, how to use delete operator to delete one of the object properties.
A) delete O
B) delete x
C) delete O.x
D) All of the above

18. ………………. operator evaluates its operand, then discards the value and returns undefined.
A) In
B) Eval
C) Comparison
D) Void

19. In client side JavaScript, ………………….. allows you to evaluate an expression for its side effects without the browser displaying the value of evaluated expression.
A) In
B) Eval
C) Comparison
D) Void

20. The unary operator typeof returns …………… if the operand value is Null.
A) “undefined”
B) “object”
C) “boolean”
D) “string”

Answers

1. B) = =
2. C) = = =
3. A) !=
4. C) != =
5. A) = =
6. B) True, True
7. B) i-False, ii-True, iii-True
8. A) <
9. D) >=
10. C) Number
11. A) False
12. A) False
13. A) False
14. C) instanceOf
15. B) in
16. D) logical
17. C) delete O.x
18. D) Void
19. D) Void
20. B) “object”

Read Next:Top 30 Multiple Choice Questions On JavaScript Object

Author

Shuseel Baral is a web programmer and the founder of InfoTechSite has over 8 years of experience in software development, internet, SEO, blogging and marketing digital products and services is passionate about exceeding your expectations.

1 Comment