Q. In a case, where the value of the operator is NULL , the typeof returned by the unary operator is___.

  • (A) undefined
  • (B) string
  • (C) boolean
  • (D) object
πŸ’¬ Discuss
βœ… Correct Answer: (D) object
Explanation:

Let's solve it carefully:

In JavaScript, if the value is null, and you apply the typeof unary operator, for example:

typeof null

Then the result is: "object".

Reason:

  • It's a well-known historical bug in JavaScript:
    typeof null returns "object", even though null is a primitive.
  • This behavior is maintained for backward compatibility.

Therefore, the correct answer is:

(D) object

Explanation by: Mr. Dubey

Let's solve it carefully:

In JavaScript, if the value is null, and you apply the typeof unary operator, for example:

typeof null

Then the result is: "object".

Reason:

  • It's a well-known historical bug in JavaScript:
    typeof null returns "object", even though null is a primitive.
  • This behavior is maintained for backward compatibility.

Therefore, the correct answer is:

(D) object

πŸ’¬ Discussion


πŸ“Š Question Analytics

πŸ‘οΈ
243
Total Visits
πŸ“½οΈ
4 y ago
Published
πŸŽ–οΈ
Akshay Kulkarni
Publisher
πŸ“ˆ
85%
Success Rate