29

Is there a way to detect Google Chrome's version from the console. I know I can parse the user agent string - but I prefer a more concise way.

Here is what I currently have:

var uaStr = navigator.userAgent.toLowerCase();
var index = uaStr.indexOf('chrome/');
uaStr.substring(index +7,index+11);

I would like to know if there's a better way - something like chrome.version()

Thanks.

Rubinsh
  • 4,457
  • 10
  • 32
  • 40
  • 1
    Looks like all solutions out there (at least the ones I could find via a quick search) use the User Agent, such as http://stackoverflow.com/questions/5916900/how-can-you-detect-the-version-of-a-browser – CBroe Nov 16 '15 at 12:51
  • [Chrome has some APIs](https://developer.chrome.com/extensions/api_index) a bit like the one you imagined, but as of this comment in 2019, there doesn't seem to be one for version. A future reader of this comment may find they've added it. – Chris Sep 08 '19 at 17:17

1 Answers1

53

In Chrome DevTools Console execute the following statement:

 > navigator.appVersion.match(/.*Chrome\/([0-9\.]+)/)[1]

And you will get the version number as a string

 > "51.0.2704.103"
Gilad Foyer
  • 923
  • 1
  • 9
  • 10