You are viewing a single comment's thread from:

RE: Refactoring For Reusability: Day Seven of "The Complete Node.js Developer Course"

in #javascript7 years ago

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 :)

Sort:  

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

int a = 0;
if (a){...}  // = false

int b = anything but 0
if (b) {...} // = true

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 contain true or false 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.

Coin Marketplace

STEEM 0.18
TRX 0.16
JST 0.030
BTC 68195.23
ETH 2703.52
USDT 1.00
SBD 2.78