Sometimes, the type of data which are retrieved from apis is bitter vague, such as { code: 2, name: 'fengxh', type: 'human' } or { code: '2', type: 'clothes' }, from two different apis. So more codes to directly use ===, unless a workaround +code === 2. But I still recommend using ===
In section "The '===' Operator" the result of :
let a=1;
let b='1';
let c=true;
console.log(a===b);
console.log(a==c);
the output on the console wouldn't be:
false
true
?
Very good article, thank you.
I really liked the way you have used images.
Awesome stuff!
The title of your post does not match your conclusion. The reason people tend to use triple equals is that they are not entirely sure what they are comparing. However, if you know both operands is a certain type, double equals are fine.
If you would tell me to write a web application from scratch, I would use double equals, the reason is to force people to write deterministic code.
Thanks for the tip. I recommend using === almost every time unless there is a compelling reason not to. == can introduce unexpected bugs that are hard to find and fix.
Juan David
cada fuerte en algún moemnto fue debil
la verdad es algo que es tan basico que se aborda en la documentación y lo dejamos pasar. Que buen aclaración.