Its about javascript
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our W3Make Forum to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
These are equality operators which are used for comparison. The difference is :-
== :- It does the type conversion of the operands before comparison , basically change the data type of one of the two operands if both are not same.
For ex:-
let x=100
let y=’100′
console.log(x==y);
output:- true
It’s true because it has changed the data type of y .
=== :- It doesn’t do the type conversion of the operands before comparison, basically do not change the data type of the operands.
Example:-
let x=100
let y=’100′
console.log(x===y);
output:- false
it’s false because it has not changed datatype of y.
In java, we use “==” and “===” for comparison.
The “==” operator also called the “loose equality” operator, compares two values for equality after performing type coercion if necessary. i.e., it automatically converts one data type to another when any operations or comparisons are to be done.
For eg: console.log(10 == “10”); // in this it converts the string “10” to number 10 and hence returns the value, true.
The “===” operator, also known as “strict equality” operator, compares the values without performing any type coercion. So,
console.log(10 == =“10”); // As one is a string and other is a number this returns false, since there is no type coercion done.