Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trial
aroshinemunasinghe
5,649 PointsWhat is === ? is it the same like ==?
Hi
I want to know what is different between == and === ? is === for objectives? Please show some examples.
2 Answers
silvercoder
11,113 PointsPaolo Scamardella
24,828 PointsThe difference between === and == is that === checks for the value and type while == checks for the value only.
Example,
const a = 1;
const b = 1;
console.log(a === b); // true
console.log(a == b); // true
const c = 1;
const d = '1';
// Here you are checking for both the value, which both are equal to 1,
// but you are also checking for the data type, which both have different data types.
// c is an integer while d is a string
console.log(c === d); // false
// Here you are only checking for the value, which both are equal to 1
console.log(c == d); // true