Answers for "is an empty string falsy in js"

17

javascript if string empty

// Test whether strValue is empty or is None
if (strValue) {
    //do something
}
// Test wheter strValue is empty, but not None 
if (strValue === "") {
    //do something
}
Posted by: Guest on May-25-2020
0

is empty string falsy

// This is dependent on the language you are using.
// In most high-level-languages (like JavaScript or Python) they are falsy.
if (""){
	console.log("This will never execute")
}

// However many low-level-languages (like C or C++) they are truthy, because
// they are just a pointer to some container, and a pointer that doesn't
// point to null is truthy.
Posted by: Guest on December-18-2021

Code answers related to "Javascript"

Browse Popular Code Answers by Language