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

242 B

title, tags
title tags
getProtocol browser,beginner

Returns the protocol being used on the current page.

  • Can be either http: or https:
const getProtocol = () => window.location.protocol;
getProtocol(); // 'https:'