Data Structure
 Networking
 RDBMS
 Operating System
 Java
 MS Excel
 iOS
 HTML
 CSS
 Android
 Python
 C Programming
 C++
 C#
 MongoDB
 MySQL
 Javascript
 PHP
- Selected Reading
 - UPSC IAS Exams Notes
 - Developer's Best Practices
 - Questions and Answers
 - Effective Resume Writing
 - HR Interview Questions
 - Computer Glossary
 - Who is Who
 
Difference between != and !== operator in JavaScript Program
'!=' comparison operator
'!=' operator checks the unequality of two objects without making the type check. It converts the datatype of two operands to one and then compares their value. For example 1 != '1' will results false.
'!==' comparison operator
'!==' operator checks the unequality of two objects with a type check. It does not converts the datatype and makes a typed check.For example 1 !== '1' will results true.
Following example, shows usage of '!=' vs '!==' operators.
Example
<!DOCTYPE html>
<html>
<head>
   <title>Operator Example</title>
</head>
<body>
   <script language="JavaScript">
      console.log(" 1 != '1' " + (1 != '1'));
      console.log(" 1 !== '1' " + (1 !== '1'));
   </script>
</body>
</html>
Output
1 != '1' false 1 !== '1' true
Advertisements