1D0-735 practice question 11 of 15

Which of the following comparison statements will return true?

Full set: 55 questions
Answer options
A: X = 15 ; Y = 3 ; X == y ;
B: X=15 Y=3; X +==45;
C: X = 15 Y = 3; X ! == y; Correct answer
D: X = 15 Y = 3 X === y;
Correct Answer:
C. X = 15 Y = 3; X ! == y;
Explanation

The statement X !== y uses the strict inequality operator. This operator evaluates whether its two operands are not equal, returning a Boolean result. It checks for inequality in both value and type without performing any type coercion. In this case, X is the number 15 and Y is the number 3. Since the value 15 is not equal to the value 3, the expression 15 !== 3 correctly evaluates to true.

Why Incorrect

A. The == (equality) operator returns false because the value 15 is not equal to the value 3.
B. The operator +== is not a valid assignment or comparison operator in JavaScript and will cause a SyntaxError.
D. The === (strict equality) operator returns false because the value 15 is not equal to the value 3.

References

1. Mozilla Developer Network (MDN) Web Docs: "The strict inequality operator (!==) checks whether its two operands are not equal, returning a Boolean result. Unlike the inequality operator, the strict inequality operator always considers operands of different types to be different."

Source: MDN Web Docs, Comparison operators, Section: "Strict inequality (!==)".

2. ECMAScript® 2024 Language Specification (ECMA-262, 15th Edition): The specification defines the behavior of the strict inequality operator. The expression x !== y is defined as the logical negation of the Strict Equality Comparison x === y. For two numbers, x === y is true only if they have the same numeric value. Since 15 and 3 do not, 15 === 3 is false, making 15 !== 3 true.

Source: ECMA-262, 15th Edition, June 2024, Section 13.11.4, "Runtime Semantics: Evaluation" for RelationalExpression : RelationalExpression !== ShiftExpression.

3. W3C (used in many university curricula): The JavaScript Comparison and Logical Operators documentation, often referenced in academic settings, explains that !== returns true if the operands are not equal and/or not of the same type.

Source: W3C, JavaScript Comparison and Logical Operators, Section: "Comparison Operators". (Note: While W3C provides tutorials, the core specification is ECMA-262).

Scroll to Top