bagaimana mengetahui internet yang terhubung di JS

// example code
let Connected = window.navigator.onLine;
if (Connected) {
  alert('Connection available');
} else {
  alert('Connection not available');
}
Abhay Mishra