Q. The statement p===q refers to _________
β
Correct Answer: (D)
Both p and q are equal in value and type
Explanation:
In JavaScript, the === (strict equality operator) checks both:
- Value equality (i.e., p and q must have the same value)
- 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.