Update snippet descriptions
This commit is contained in:
@ -1,11 +1,11 @@
|
||||
---
|
||||
title: detectDeviceType
|
||||
tags: browser,intermediate
|
||||
tags: browser,regexp,intermediate
|
||||
---
|
||||
|
||||
Detects whether the website is being opened in a mobile device or a desktop/laptop.
|
||||
Detects whether the page is being viewed on a mobile device or a desktop.
|
||||
|
||||
- Use a regular expression to test the `navigator.userAgent` property to figure out if the device is a mobile device or a desktop/laptop.
|
||||
- Use a regular expression to test the `navigator.userAgent` property to figure out if the device is a mobile device or a desktop.
|
||||
|
||||
```js
|
||||
const detectDeviceType = () =>
|
||||
@ -16,4 +16,4 @@ const detectDeviceType = () =>
|
||||
|
||||
```js
|
||||
detectDeviceType(); // "Mobile" or "Desktop"
|
||||
```
|
||||
```
|
||||
|
||||
Reference in New Issue
Block a user