Difference between != and !== operator in JavaScript Last Updated : 29 Dec, 2023 Comments Improve Suggest changes 3 Likes Like Report != operatorThe inequality operator (!=) is the logical opposite of the equality operator. It means "Not Equal" and returns true whereas equality would return false and vice versa. Like the equality operator, the inequality operator will convert data types of values while comparing. For example 1 != '1' will return false since data type conversion takes place so 1 and '1' are considered equal. Example: Below example shows != Operator. JavaScript console.log(" 1 != '1' " + (1 != '1')); console.log(" 1 != 1 " + (1 != 1)); console.log(" 1 != '2' " + (1 != '2')); Output 1 != '1' false 1 != 1 false 1 != '2' true !== operatorThe strict inequality operator (!==) is the logical opposite of the strict equality operator. It means "Strictly Not Equal" and returns true whereas strict equality would return false and vice versa. Strict inequality will not convert data types. For example 1 !== '1' will return true since 1 is an integer and '1' is a character and no data type conversion takes place. Example: Below example shows !== Operator. JavaScript console.log(" 1 !== '1' " + (1 !== '1')); console.log(" 1 !== 1 " + (1 !== 1)); console.log(" 1 !== '2' " + (1 !== '2')); Output 1 !== '1' true 1 !== 1 false 1 !== '2' true Difference between != and !== operator in JavaScriptFeature!= (Loose Inequality)!== (Strict Inequality)Type CoercionConverts values to the same type for comparison.Compares values without changing their types.Example5 != "5" is false5 !== "5" is trueUsage RecommendationUse with caution as it may lead to unexpected results due to type coercion.Preferred in most cases to ensure both value and type are considered. It's more explicit and reduces the chance of unexpected behavior. Create Quiz Comment R ranadeepika2409 Follow 3 Improve R ranadeepika2409 Follow 3 Improve Article Tags : JavaScript Web Technologies JavaScript-Questions Explore JavaScript BasicsIntroduction to JavaScript4 min readVariables and Datatypes in JavaScript6 min readJavaScript Operators5 min readControl Statements in JavaScript4 min readArray & StringJavaScript Arrays7 min readJavaScript Array Methods7 min readJavaScript Strings5 min readJavaScript String Methods9 min readFunction & ObjectFunctions in JavaScript5 min readJavaScript Function Expression3 min readFunction Overloading in JavaScript4 min readObjects in JavaScript4 min readJavaScript Object Constructors4 min readOOPObject Oriented Programming in JavaScript3 min readClasses and Objects in JavaScript4 min readWhat Are Access Modifiers In JavaScript ?5 min readJavaScript Constructor Method7 min readAsynchronous JavaScriptAsynchronous JavaScript2 min readJavaScript Callbacks4 min readJavaScript Promise4 min readEvent Loop in JavaScript4 min readAsync and Await in JavaScript2 min readException HandlingJavascript Error and Exceptional Handling6 min readJavaScript Errors Throw and Try to Catch2 min readHow to create custom errors in JavaScript ?2 min readJavaScript TypeError - Invalid Array.prototype.sort argument1 min readDOMHTML DOM (Document Object Model)8 min readHow to select DOM Elements in JavaScript ?3 min readJavaScript Custom Events4 min readJavaScript addEventListener() with Examples9 min readAdvanced TopicsClosure in JavaScript4 min readJavaScript Hoisting6 min readScope of Variables in JavaScript3 min readJavaScript Higher Order Functions7 min readDebugging in JavaScript4 min read Like