Files
30-seconds-of-code/snippets/getProtocol.md
2020-10-08 15:24:58 +03:00

17 lines
302 B
Markdown

---
title: getProtocol
tags: browser,beginner
---
Returns the protocol being used on the current page.
- Use `window.location.protocol` to get the protocol (`http:` or `https:`) of the current page.
```js
const getProtocol = () => window.location.protocol;
```
```js
getProtocol(); // 'https:'
```