Truthy or Falsy, 29/100 Days of Code
I learned a cool concept about JavaScript while working in codecademy this week.
Truthy and Falsy are two values in JavaScript used to determine whether or not a variable contains a value. If a variable has been assigned certain values, it is considered truthy. This can be a number, a string literal, true boolean value, you name it. In other words, a defined variable typically has the value of truthy.
However, this is not always the case. Sometimes defined variables can be considered falsy. According to the documents on the Mozilla developer website, false, 0, empty strings (“”), null, undefined, and Not a Number (NaN) are the only values which, when assigned to variables, give them a value of falsy.
It’s cool learning different programming languages. Codecademy definitely helped me along the way. I enjoy learning about the different features in each language. Sure, building apps is one way to learn. Playing with different examples is great too.
-CF