Update snippet descriptions

This commit is contained in:
Isabelle Viktoria Maciohsek
2020-10-19 18:51:03 +03:00
parent f0fbe0c3e5
commit 5e8e6f51a3
36 changed files with 97 additions and 82 deletions

View File

@ -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"
```
```