What is difference between == & === in servicenow
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-20-2022 08:42 PM
What is difference between == & === in ServiceNow
Please tell me this one and also any other operator related to this onw
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-20-2022 09:04 PM - edited 11-20-2022 09:16 PM
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
Best Regards,
Nayan Dhamane
ServiceNow Community Rising Star 2023.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-20-2022 09:08 PM
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, includingNaN
. 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
andUndefined
types are==
(but not===
). [I.e. (Null==Undefined
) istrue
but (Null===Undefined
) isfalse
]
== 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.