Q
What is the result of '5' - 2?

Answer & Solution

Answer: Option A
Solution:
When the - operator is used, JavaScript tries to convert the string to a number, so '5' - 2 evaluates to 3.
Related Questions on Average

Which operator checks if two values are not equal and also checks for type?

A). !=

B). !==

C). <

D). >

What does the typeof operator return for an array?

A). object

B). array

C). list

D). collection

What does the !! operator do to a value?

A). Negates the value

B). Converts the value to its boolean equivalent

C). Increments the value by 2

D). No effect

Which of the following is a logical operator in JavaScript?

A). &&

B). ||

C). !

D). All of the above

What does the + operator do when used with two numbers?

A). Concatenates them as strings

B). Adds them

C). Multiplies them

D). Subtracts them

What is the result of 5 === '5'?

A). 1

B). 0

C). 1

D). 0

Which of the following is not a comparison operator?

A). ==

B). >

C). <=

D). =

What is the result of true + false?

A). 0

B). 1

C). truefalse

D). NaN

What is the value of the expression null == undefined?

A). 1

B). 0

C). null

D). undefined

What is the result of 10 % 3 in JavaScript?

A). 0

B). 1

C). 2

D). 3