# Which Operator Is Used to Check if Two Values Are Equal and of Same Data Type Quizlet?

//

Scott Campbell

Welcome to this in-depth tutorial on the operator used to check if two values are equal and of the same data type. In JavaScript, this operator is known as the strict equality operator, represented by ===.

## What is the strict equality operator?

The strict equality operator is used to compare two values to determine if they are equal in both value and data type. It returns true if the values are equal and of the same data type, otherwise it returns false.

## How does it work?

When using the strict equality operator, JavaScript compares the values on both sides of the operator. It first checks if they have the same data type. If they do not, it immediately returns false.

This means that a number will never be equal to a string when using the strict equality operator.

If both values have the same data type, JavaScript then compares their actual values. If the values are identical, it returns true. Otherwise, it returns false.

## Examples:

Let’s take a look at some examples to better understand how the strict equality operator works:

### Example 1: Numbers

• `10 === 10`: Returns true, since both values are numbers and equal.
• `10 === '10'`: Returns false, since one value is a number and the other is a string.
• `10 === 5`: Returns false, since both values are numbers but not equal.

### Example 2: Strings

• `'hello' === 'hello'`: Returns true, since both values are strings and equal.
• `'hello' === 'world'`: Returns false, since both values are strings but not equal.

### Example 3: Booleans

• `true === true`: Returns true, since both values are booleans and equal.
• `true === false`: Returns false, since both values are booleans but not equal.

## Conclusion:

The strict equality operator (===) is a powerful tool in JavaScript for checking if two values are equal and of the same data type. It ensures that you are comparing values accurately, taking into account their data types. Remember to use the strict equality operator when you need to perform precise comparisons in your code.

Now that you have a solid understanding of the strict equality operator, go ahead and apply this knowledge in your own JavaScript projects!