Files
30-seconds-of-code/snippets/getProtocol.md
2020-10-06 15:40:53 -07:00

17 lines
242 B
Markdown

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