Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

truthy and falsy

if (true)
if ({})
if ([])
if (42)
if ("0")
if ("false")
if (new Date())
if (-42)
if (12n)
if (3.14)
if (-3.14)
if (Infinity)
if (-Infinity)
Comment

truthy or falsy

function truthyOrFalsy(arg) {
  arg ? console.log('truthy') : console.log('falsy');
}
truthyOrFalsy(''); // falsy
truthyOrFalsy('str'); // truthy
truthyOrFalsy(0); // falsy
truthyOrFalsy(1); // truthy
truthyOrFalsy([]); // truthy
truthyOrFalsy({}); // truthy
console.log(!'', !!''); // true false
console.log(!'str', !!'str'); // false true
console.log(!0, !!0); // true false
console.log(!1, !!1); // false true
console.log(![], !![]); // false true
console.log(!{}, !!{}); // false true
Comment

PREVIOUS NEXT
Code Example
Javascript :: clear input field react 
Javascript :: JavaScript built-in methods 
Javascript :: javascript Adding Element to the Outer Array 
Javascript :: JavaScript Number Objects 
Javascript :: Export Multiple Objects 
Javascript :: reading an array from python to js 
Javascript :: javascript remaining elements of an array to a variable using the spread syntax 
Javascript :: xhr.upload 
Javascript :: JavaScript Generator Function With return 
Javascript :: javascript function definitions 
Javascript :: javascript even/uneven numbers 
Javascript :: jQuery - Set 
Javascript :: chart js svg word map 
Javascript :: js regex find newlines 
Javascript :: roman to integer fastest way 
Javascript :: node add dependency 
Javascript :: phaser wrap in camera bounds 
Javascript :: phaser animation show on start 
Javascript :: how to process string calculation in gdscript 
Javascript :: js undici 
Javascript :: nodejs: redirect path to specific path 
Javascript :: documentUrlPatterns 
Javascript :: expected a string (for built-in components) or a class/function (for composite components) but got: undefined 
Javascript :: regex capture group example 
Javascript :: sorting an array 
Javascript :: Remove escape characters from JSON Data 
Javascript :: constructer 
Javascript :: mongoose getters 
Javascript :: var function js 
Javascript :: javascript function syntax 
ADD CONTENT
Topic
Content
Source link
Name
5+4 =