How to check if Array Object is empty or not

How to check if Array Object is empty or not

by umangparekh

HTML

<h1>How to check if Array object is Empty or not</h1>

<h3>
  To check the output of below JS code please open console using<br/>
  <span style="color:blue">F12 or Ctrl+Shift+J</span>
</h3>

JavaScript

var myArray = [];

console.log("If Array is empty", myArray.length); // Output would be "0"

myArray.push("1");

myArray.push("2");

console.log("If Array is empty", myArray.length); // Output would be "2"