Skip to content

Commit b2d0d5e

Browse files
authored
get device orientation
get device orientation
1 parent b34f9d1 commit b2d0d5e

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

README.md

+15-3
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,7 @@
4949
|43 | [toFixed](#toFixed)|
5050
|44 | [generate randomUUID](#generate-random-uuid)|
5151
|45 | [structuredClone](#structuredClone)|
52-
53-
54-
52+
|46 | [get device orientation](#get-device-orientation)|
5553

5654

5755
**[⬆ Back to Top](#table-of-contents)**
@@ -981,4 +979,18 @@ console.log("clonedUser.address.street:", clonedUser.address.street);
981979
// > New Road
982980
983981
982+
```
983+
984+
**[⬆ Back to Top](#table-of-contents)**
985+
### get device orientation
986+
987+
Browsers expose a global variable named screen, which we’ll use to access the information we need.
988+
989+
```javascript
990+
991+
function getOrientation() {
992+
const isPortrait = screen.orientation.type.startswith('portrait')
993+
return isPortrait ? 'portrait' : 'landscape'
994+
}
995+
984996
```

0 commit comments

Comments
 (0)