Beginner

Understanding Equality Operators (== vs ===)

Description

In JavaScript, there are two main equality operators:

  • == (loose equality) Compares values for equality after performing type coercion if necessary.
  • === (strict equality) Compares values and their types without type coercion.

Your task is to write a function that takes two inputs and returns true if they are strictly equal (using ===) and false otherwise.

This exercise will help you understand when to use strict equality to avoid unexpected behavior caused by type coercion.

Example differences:

  • 5 == "5" returns true because == converts the string to a number before comparison. = 5 === "5" returns false because they are different types (number vs string).

Example usage:

console.log(strictEqualityCheck(5, "5"));
// Expected output: false
console.log(strictEqualityCheck(10, 10));
// Expected output: true
console.log(strictEqualityCheck(0, false));
// Expected output: false
console.log(strictEqualityCheck(null, undefined));
// Expected output: false

window code 2Test Cases

Input:

10

Expected Output:

true