Basic and Conditional Line Breakpoints6:58 with Joel Kraft
Setting breakpoints on specific lines may be the most common ones you'll set.
Covered in this Video
- Line breakpoint
- Conditional line breakpoint
Equality vs. Identity (
== (equality operator) and
==. The reason is that in certain cases, predicting how
== will behave can be counterintuitive. That's because the interpreter will make assumptions about how to treat the values you place on either side of
For example, consider
12 == '12' // true
Here, the interpreter will convert the string on the right to a number before comparing the two values and return true as a result. It's kind of saying, "I think you meant to give me a number for this second value. That's ok, I'll just change it for you."
Leaving ambiguity up to the interpreter to decide for you can lead to trouble in ways that are hard to predict. Moreover, bugs having to do with these assumptions can be hard to find!
That's why developers often prefer
=== for comparing values.
12 === '12' // false 12 === 12 // true
It helps them write code that's easy to understand, not only at the time of writing, but later, when reading back over the code.
Here's an MDN article on this topic for a little more depth.
You need to sign up for Treehouse in order to download course files.Sign up