JavaScript Example | Check the Input Checkbox is Checked or not

This JavaScript example code shows how to check an input type checkbox is checked or not.

<input type="checkbox" onchange="getChecked()" id='check1'>

function getChecked() {
  const checkBox = document.getElementById('check1').checked;
  if (checkBox === true) {
    console.log(true);
    } else {
      console.log(false);
  }
}