We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent df37529 commit 1cbbac9Copy full SHA for 1cbbac9
1 file changed
js-coding-technique/userOS.js
@@ -0,0 +1,22 @@
1
+function getUserOS() {
2
+ let device = 'Unknown';
3
+ const ua = {
4
+ 'Generic Linux': /Linux/i,
5
+ Android: /Android/i,
6
+ BlackBerry: /BlackBerry/i,
7
+ Bluebird: /EF500/i,
8
+ 'Chrome OS': /CrOS/i,
9
+ Datalogic: /DL-AXIS/i,
10
+ Honeywell: /CT50/i,
11
+ iPad: /iPad/i,
12
+ iPhone: /iPhone/i,
13
+ iPod: /iPod/i,
14
+ macOS: /Macintosh/i,
15
+ Windows: /IEMobile|Windows/i,
16
+ Zebra: /TC70|TC55/i,
17
+ };
18
+ Object.keys(ua).map((v) => navigator.userAgent.match(ua[v]) && (device = v));
19
+ return device;
20
+}
21
+
22
+console.log({OS: getUserOS()});
0 commit comments