Categories
JavaScript Answers

How to detect 64-bit or 32-bit Windows from user agent with JavaScript?

Spread the love

Sometimes, we want to detect 64-bit or 32-bit Windows from user agent with JavaScript.

In this article, we’ll look at how to detect 64-bit or 32-bit Windows from user agent with JavaScript.

How to detect 64-bit or 32-bit Windows from user agent with JavaScript?

To detect 64-bit or 32-bit Windows from user agent with JavaScript, we can use the navigator.userAgent string property.

For instance, we write

if (
  navigator.userAgent.includes("WOW64") ||
  navigator.userAgent.includes("Win64")
) {
  console.log("This is a 64 bit OS");
} else {
  console.log("Not a 64 bit OS");
}

to check if navigator.userAgent includes 'WOW64' or the 'Win64' strings.

If it includes either one, then the user agent is the 64 bit Windows user agent.

Conclusion

To detect 64-bit or 32-bit Windows from user agent with JavaScript, we can use the navigator.userAgent string property.

By John Au-Yeung

Web developer specializing in React, Vue, and front end development.

Leave a Reply

Your email address will not be published. Required fields are marked *