Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

js enum

const daysEnum = Object.freeze({
  monday: 0,
  tuesday: 1,
  wednesday: 2,
  thursday: 3,
  friday: 4,
  saturday: 5,
  sunday: 6
});
Comment

javascript enum

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:
  // Do something for summer beginning
  case seasons.SUMMER.ENDING:
  // Do something for summer ending
  case seasons.SUMMER:
  // This will work if season = seasons.SUMMER
  // Do something for summer (generic)
  case seasons.WINTER:
  //Do something for winter
  case seasons.SPRING:
  //Do something for spring
  case seasons.AUTUMN:
  //Do something for autumn
}
Comment

enum javascript

const DaysEnum = {"monday":1, "tuesday":2, "wednesday":3, ...}
Object.freeze(DaysEnum)
Comment

PREVIOUS NEXT
Code Example
Javascript :: open each image on its own modal page 
Javascript :: socket io across two different ports 
Javascript :: puppeeter pdf desktop 
Javascript :: Merge Arrarys of Object of Any size 
Javascript :: emacs some part of the text read only 
Javascript :: Snail array 
Javascript :: ngreadonly 
Javascript :: Uncaught TypeError: table.fnColReorder.transpose is not a function 
Javascript :: enzym.debug 
Javascript :: change active menu item on page scroll javascript 
Javascript :: extending classes javascript 
Javascript :: test command in node js 
Javascript :: react proxy to flask server 
Javascript :: jq unique by object attribute in list 
Javascript :: Fromdata 
Javascript :: xstate vu.js 
Javascript :: Handle Race Condition in Node Js using Mutex 
Javascript :: await multiple promises 
Javascript :: is element displayed js 
Javascript :: javascript call function from event handler es6 
Javascript :: react router v6 wrapped routes in separate files 
Javascript :: Node-Red Custom UI 
Javascript :: split name js 
Javascript :: JAVASCRIPT EX. 
Javascript :: How to Compare Strings Using localeCompare 
Javascript :: react with two components render 
Javascript :: JSON: remember you can use a value that comes later 
Javascript :: https://graph.instagram.com/14.0/17841450694979740 
Javascript :: How to Solve the Staircase Problem with 5 Lines of JavaScript 
Javascript :: prisma nested create 
ADD CONTENT
Topic
Content
Source link
Name
3+7 =