JavaScript JavaScript and the DOM Making Changes to the DOM Styling Elements

1 Answer

Jason Hill
Jason Hill
Full Stack JavaScript Techdegree Student 11,399 Points

So the difference is the == is 'loose' equality, and the ===is STRICT. The === will check that the type and the value compared are the same, while ==will try to convert two types then compare.
ex: true === true is true, 77 === 77 is true however 77 === '77' is false, because '77' is a string. While 77 == '77'will be true, even though one is a string as well as false == 0, will be true. It is called type coercion. Checkout MDN for more info! If this helps you can select it as best answer.

Andrew Hickman
Andrew Hickman
Full Stack JavaScript Techdegree Student 2,281 Points

Yes. A good rule of thumb is to ALWAYS use ===, just like it is always good to write a "use strict" statement at the top of your files. It basically forces you to write good code.