The Zurich release has arrived! Interested in new features and functionalities? Click here for more

What is difference between == & === in servicenow

Basha4
Tera Expert

What is difference between == & === in ServiceNow

Please tell me this one and also any other operator related to this onw

2 REPLIES 2

Nayan  Dhamane
Kilo Sage
Kilo Sage

Hello @Basha4 ,

 

The main difference between the two is == check for same values and '===' also checks for the datatype to be same as well.

 

=== is a strict comparison operator. For strict equality the objects being compared must have the same type and:

  • Two strings are strictly equal when they have the same sequence of characters, same length, and same characters in corresponding positions.
  • Two numbers are strictly equal when they are numerically equal (have the same number value). NaN is not equal to anything, including NaN. Positive and negative zeros are equal to one another.
  • Two Boolean operands are strictly equal if both are true or both are false.
  • Two objects are strictly equal if they refer to the same Object.
  • Null and Undefined types are == (but not ===). [I.e. (Null==Undefined) is true but (Null===Undefined) is false]

 

For more information you can view the below posts as well:

JavaScript — Double Equals vs. Triple Equals

3 Equal Signs? How is it used?

BR,
Nayan

If my answer solved your issue, please mark my answer as Correct & Helpful based on the Impact

Best Regards,
Nayan Dhamane
ServiceNow Community Rising Star 2023.

Gunjan Kiratkar
Kilo Patron
Kilo Patron

Hi @Basha4 ,

=== is a strict comparison operator. For strict equality the objects being compared must have the same type and:

  • Two strings are strictly equal when they have the same sequence of characters, same length, and same characters in corresponding positions.
  • Two numbers are strictly equal when they are numerically equal (have the same number value). NaN is not equal to anything, including NaN. Positive and negative zeros are equal to one another.
  • Two Boolean operands are strictly equal if both are true or both are false.
  • Two objects are strictly equal if they refer to the same Object.
  • Null and Undefined types are == (but not ===). [I.e. (Null==Undefined) is true but (Null===Undefined) is false]

== In JavaScript, the “==” operator is a comparison operator. This means that you can perform logic tests to see if one thing is equal to another thing. The result will always return either true or false.

With “==”, JavaScript does not care what data type (string or integer) you pass to it as long as the content that you provided it with matches.


Please Mark My Response as Correct/Helpful based on Impact
Regards,
Gunjan Kiratkar
2X ServiceNow MVP
Community Rising Star 2022
Youtube : ServiceNow Guy