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 :: json file with multiple records 
Javascript :: read file size javascript 
Javascript :: generate id js 
Javascript :: users api testing 
Javascript :: ajax done 
Javascript :: get random entry from array javascript 
Javascript :: check if element is visible or hidden in dom 
Javascript :: delay input javascript 
Javascript :: toaster for angular 
Javascript :: center element in react native 
Javascript :: rounding up a number so that it is divisible by 5 javascript 
Javascript :: opencv rtsp stream python 
Javascript :: expo build ios 
Javascript :: export apk react native 
Javascript :: code challenges javascript 
Javascript :: reactbootstrap multiselect 
Javascript :: pi in js 
Javascript :: jquery boilerplate 
Javascript :: readystate in ajax 
Javascript :: jquery scroll to element id 
Javascript :: jquery find div with data attribute value 
Javascript :: notice before reload js 
Javascript :: dynamic folder import javascript 
Javascript :: javascript remove style 
Javascript :: how to know if a number has a decimal number js 
Javascript :: ERESOLVE unable to resolve dependency tree 
Javascript :: change source of image jquery 
Javascript :: javascript get gps location 
Javascript :: ion input ios keyboard over 
Javascript :: redux devtools extension 
ADD CONTENT
Topic
Content
Source link
Name
4+8 =