Example 1 — Read onLine
Print the current Boolean status.
console.log(navigator.onLine); How It Works
- Read the property. Returns a Boolean, not a string.
truemeans “thinks online.” Not proof of Internet.falsemeans “thinks offline.” Still verify with real requests.- Read-only. You cannot assign a new value.

