Truthy or Falsy?

  1. undefined
  2. “” (an empty string)
  3. null
  4. NaN
  5. 0
  6. false
let name = "" //=> falsy
let name = "Grace" //=> truthy
function fizz_buzz() {
for(i = 0; i < 100)
console.log((++i % 3 ? "" : "fizz") && (i % 5 ? "" : "buzz") || i)
}
let name = ""
console.log(!!name) // => false
let greeting = "hello"
console.log(!!greeting) // => true
let array = ['Grace', '', 'software engineer', 0, false]
console.log(array.filter(Boolean)
// => ['Grace', 'software engineer']

--

--

--

Fullstack Software Engineer | Musician | Food Lover | Coffee Addict

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Notes on Learning Redux

Coding for Scrubs: Return The Updated Day (JS)

Setup Nest and Firebase Functions in a new project

Why functions are called First-Class Citizens in JavaScript

Deploying To GitHub Pages With Gulp

Understand the Node.js Event-Loop

Creating Your First Chrome Extension

How to Add Version to Angular Application

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Grace Yuiko Nakano

Grace Yuiko Nakano

Fullstack Software Engineer | Musician | Food Lover | Coffee Addict

More from Medium

How To Marry Your Neighbor: The Introverts Guide To Ever After

I Never Fail My New Year’s Resolutions

Let’s Fall in Love for the Night

How do you walk into a medical appointment?