You are viewing a single comment's thread from:
RE: Refactoring For Reusability: Day Seven of "The Complete Node.js Developer Course"
I believe the "if (note)" handles checks against undefined and also null so a little more complete.
Yep always good to refactor so everything does one thing and does it well. They become easier to plug together, smaller lego blocks are easier to build into complex things than less but bigger blocks, you get more control :)
Okay, so
if (note)
checks to see if note exists. If note exists, it can't be undefined or null. I think I get it.All languages have their quirks. Take this in C
It gets abused in that language a fair bit :)
Exactly. By default, every uninitialized object in Javascript equals to
undefined
. If you want to learn a bit more about this behaviour, you should check this link that talks about Truthy and Falsy elements: some objects that don't containtrue
orfalse
values, but behave the same way.I've learned a couple of new things with your posts @matthewdavid, your explanations are very simple and accurate. Keep up the good work.