How would I use this? For me, it returns undefined in both, Firefox and Chrome. The test itself returns true (as expected).
I would use match instead of test, because I also don't know how "test" should properly work in this case.
const OS = navigator.appVersion.match(/\b(?:Win|Mac|X11|Linux)/)[0]; console.log(OS);
Yeah match will work perfectly for this.
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
How would I use this? For me, it returns undefined in both, Firefox and Chrome. The test itself returns true (as expected).
I would use match instead of test, because I also don't know how "test" should properly work in this case.
Yeah match will work perfectly for this.