Is it possible to determine the user's device using JS? It does not matter what kind of data will have to operate, as long as you can distinguish one user from another.

  • so you need to: determine the user's operating system (or its browser) or get its unique identifier (such as mac-addresses)? the first is simple. - Alexey Obukhov

2 answers 2

The easiest way is to write a random value to localStorage. But if you have a server, it is even easier to use cookies for this purpose.

  • Thanks for the tip! - Ilya Bizunov

You can define a user agent in the global object navigator.userAgent and you can already recognize it by the agent and recognize the device.

 if (/Android|webOS|iPhone|iPad|iPod|BlackBerry|BB|PlayBook|IEMobile|Windows Phone|Kindle|Silk|Opera Mini/i.test(navigator.userAgent)) { // ΠŸΠΎΠ»ΡŒΠ·ΠΎΠ²Π°Ρ‚Π΅Π»ΡŒ сидит с мобильного прилоТСния ΠΈΠ»ΠΈ Ρ‚Π°Π±Π»Π΅Ρ‚ΠΊΠΈ }