How can I simplify this javascript code with arrow function?

I’m trying to simplify this code using arrow function

function Protocol() {
  if (isBrowser) {
    const protocol = window.location.protocol;
    return protocol;
const windowProtocol = Protocol();

function Host() {
  if (isBrowser) {
    const host =;
    return host;
const windowHost = Host();

It’s also repetitive, can I use only one function? I’m not sure how to do this.


Source: JavaSript – Stack Overflow

September 1, 2021
Category : News
Tags: arrow-functions | javascript

Leave a Reply

Your email address will not be published. Required fields are marked *

Sitemap | Terms | Privacy | Cookies | Advertising

Senior Software Developer

Creator of @LzoMedia I am a backend software developer based in London who likes beautiful code and has an adherence to standards & love's open-source.