Would you like to clone this notebook?

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


Enums in JS - object enum

node v6.17.1
version: 1.0.0
const seasons = { SUMMER: 'summer', WINTER: 'winter', SPRING: 'spring', AUTUMN: 'autumn' } let season = seasons.SPRING if(!season){ throw new Error('Season is not defined') } switch(season){ 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 }

no comments

    sign in to comment