Would you like to clone this notebook?

When you clone a notebook you are able to make changes without affecting the original notebook.

Cancel

Enums in JS - namespaced enums

node v6.17.1
version: 1.0.0
endpointsharetweet
const seasons = { SUMMER: { BEGINNING: "summer.beginning", ENDING: "summer.ending" }, WINTER: "winter", SPRING: "spring", AUTUMN: "autumn" }; let season = seasons.SUMMER.BEGINNING; if (!season) { throw new Error("Season is not defined"); } switch (season) { case seasons.SUMMER.BEGINNING: console.log('Its summer - beginning') break case seasons.SUMMER.ENDING: console.log('Its summer - ending') break case seasons.SUMMER: console.log('Its summer') break case seasons.WINTER: console.log('Its winter') break case seasons.SPRING: console.log('Its spring') break case seasons.AUTUMN: console.log('Its autumn') break }
Loading…

no comments

    sign in to comment