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

React hooks design patterns and creating components without class

How to use Chart.JS in Phoenix | Elixir Advanced

Playing With Auth in React Using JWT

Building a Finance App using React-Native: Groww

Gulp.js for website development

Implementing React-JSS on Next.js Projects.

Bootstrap 5 Alpha— First Look

Clean up

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

Take a Mental Holiday With These 10 Travel Books

Ronald Reagan’s Clean Water Lesson

Lexar vs SanDisk SD Cards: What’s the Difference & Which’s Better

How do they keep doing this?