Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

javascript truthy values


// this alls are truthy values including empty object and array,
// excluding empty string (empty string is falsy value)
if ([]) {
  console.log('✅ This runs');
}

if ({}) {
  console.log('✅ This runs');
}

if (true) {
  console.log('✅ This runs');
}

if ('test') {
  console.log('✅ This runs');
}
 
PREVIOUS NEXT
Tagged: #javascript #truthy #values
ADD COMMENT
Topic
Name
9+5 =