Heads up! To view this whole video, sign in with your Courses account or enroll in your free 7-day trial. Sign In Enroll
Start a free Courses trial
to watch this video
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 ( ==
vs. ===
)
While ==
(equality operator) and ===
(identity operator) might seem to do basically the same thing in JavaScript, many developers prefer using ===
to ==
. 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.
Related Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign upRelated Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign up
You need to sign up for Treehouse in order to download course files.
Sign upYou need to sign up for Treehouse in order to set up Workspace
Sign up