A

Admin • 802.91K Points
Coach

Q. The statement p===q refers to _________

  • (A) There is no such statement
  • (B) Both p and q are equal in value, type and reference address
  • (C) Both p and q are equal in value
  • (D) Both p and q are equal in value and type
  • Correct Answer - Option(D)
  • Views: 7
  • Filed under category JavaScript
  • Hashtags:

Explanation by: Admin

In JavaScript, the === (strict equality operator) checks both:

  1. Value equality (i.e., p and q must have the same value)
  2. Type equality (i.e., p and q must be of the same data type)

Example 1: Equal in Value and Type (true output)

var p = 10;
var q = 10;
console.log(p === q); // Output: true (same value and same type)

Example 2: Same Value, Different Type (false output)

var p = 10;       // Number
var q = "10"; // String
console.log(p === q); // Output: false (different types: number vs string)

Why Not Other Options?

  • (A) "There is no such statement" → ❌ Incorrect, because p === q is a valid JavaScript statement.
  • (B) "Both p and q are equal in value, type, and reference address" → ❌ Incorrect, because === does not compare reference addresses. It only checks value and type.
  • (C) "Both p and q are equal in value" → ❌ Incorrect, because === checks both value and type, not just value.

Final Answer:

(D) Both p and q are equal in value and type.

You must be Logged in to update hint/solution

Discusssion

Login to discuss.

Be the first to start discuss.