![]() |
In JavaScript, !== is a strict inequality operator, and undefined is a special value representing the absence of a value or the lack of an assigned value to a variable. The !== operator checks for both value and type equality, and !== undefined is used to verify if a variable is not equal to the undefined value. Table of Content Using strict inequalityThe !== operator checks for both value and type equality, and !== undefined is used to verify if a variable is not equal to the undefined value. Example: To demonstrate the use of the strict inequality operator by checking whether a number is undefined or not. Javascript
Output
5 Using equality operator with negationThe non-strict equality operator != lead to unexpected behaviour in certain cases. Using the strict inequality operator !== is generally recommended for checking against undefined. Example: To demonstrate using equality operator with negation. Javascript
Output
num is undefined. |
Reffered: https://www.geeksforgeeks.org
JavaScript |
Type: | Geek |
Category: | Coding |
Sub Category: | Tutorial |
Uploaded by: | Admin |
Views: | 9 |