diff --git a/snippets/getProtocol.md b/snippets/getProtocol.md new file mode 100644 index 000000000..52bc79f95 --- /dev/null +++ b/snippets/getProtocol.md @@ -0,0 +1,16 @@ +--- +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:' +```