How to check if a variable is empty in JavaScript

Check if a variable is empty using length property. #
example, we will use the length property to check if a variable is empty.

<script>
 const myVar="";
 if(myVar.length === 0){
   console.log("Variable is empty.");
 }else{
   console.log("Variable is not empty.")
 }
</script>


Post a Comment

0 Comments