Q
What will let x = '10'; let y = x - 5; console.log(y); output in JavaScript?

Answer & Solution

Answer: Option B
Solution:
JavaScript implicitly converts the string '10' to a number in arithmetic operations, resulting in 5.
Related Questions on Average

Which of the following is a primitive data type in JavaScript?

A). Object

B). Array

C). Function

D). Boolean

What is the outcome of typeof undefined in JavaScript?

A). String

B). Undefined

C). Null

D). Number

What is the data type of the value true in JavaScript?

A). Number

B). String

C). Boolean

D). Undefined

What will let x = null; console.log(typeof x); output in JavaScript?

A). Object

B). Null

C). Undefined

D). Number

What is the data type of the value 'null' (with quotes) in JavaScript?

A). String

B). Number

C). Null

D). Undefined

What is the data type of the value 42 in JavaScript?

A). String

B). Boolean

C). Number

D). Null

What will the following code snippet output: let a = 10; a += '5'; console.log(a); in JavaScript?

A). '105'

B). 105

C). 15

D). '15'

Which data type represents an intentional absence of any value in JavaScript?

A). Null

B). Undefined

C). String

D). Number

What will be the result of typeof 'hello' in JavaScript?

A). String

B). Number

C). Undefined

D). Function

What does NaN represent in JavaScript?

A). Not a Number

B). Infinity

C). Positive Infinity

D). Negative Infinity