DEV Community

Discussion on: Clean up your code with these tips!

Collapse
 
rhymes profile image
rhymes

Yay for a more declarative style of programming, nice walkthrough! :)

A tip for future reference, you can highlight code blocks by appending the name of the language, in this case javascript at the end of the three backticks, like this:

this is the result:

const hostnameAvailable = typeof window !== 'undefined'
    && window.hasOwnProperty('location')
    && window.location.hasOwnProperty('hostname');
const domain = hostnameAvailable ? window.location.hostname : null;
const isLocal = domain && domain.match(/localhost|127\.0\.0\.1/);
const secure = !isLocal;     

export default new Cookie({secure});
Collapse
 
dechamp profile image
DeChamp

Ha! I knew that one but assumed the site didn’t handle it. Dummy me for assuming. Thanks for the compliment and tip!