Example 1 — Basic Read
Beginner example for window.navigator.
console.log(window.navigator === navigator);
console.log(typeof navigator.userAgent); How It Works
- Step. Same as the global navigator.
- Step. userAgent is a string.

window.navigator is the Navigator object. A common field is navigator.userAgent.
Read window.navigator with no parentheses.
window.navigator; | Call | What it does |
|---|---|
window.navigator | The Navigator object (browser info). |
Window property in browsers. No import required.
| Parameter | Description |
|---|---|
| window.navigator | Read-only or assignable depending on the property. No function arguments. |
| Return Value | Description |
|---|---|
| * | The Navigator object (browser info). |
Beginner example for window.navigator.
console.log(window.navigator === navigator);
console.log(typeof navigator.userAgent); Beginner example for window.navigator.
console.log(typeof navigator.language);
console.log(navigator.language.length > 0); Beginner example for window.navigator.
console.log(typeof navigator.onLine); window.navigator is a standard Window property in browsers.
Available in all modern browsers. Not used in plain Node.js without a DOM.
Bottom line: Safe in browsers. Skip in server-only Node scripts.
Continue through the Window properties list.
CODETOFUN NEWS
Get the latest IT news, programming updates, and technology trends directly on your phone.
Your daily dose of tech, straight to your feed.
9 people found this page helpful