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 :: jquery attr 
Javascript :: leaflet each layer 
Javascript :: javascript loop over the alphabet and return the vowels 
Javascript :: javascript dir 
Javascript :: distance to km javascript 
Javascript :: @react-google-maps/api npm 
Javascript :: math ceil 
Javascript :: Sort big numbers from an array in javascript 
Javascript :: express get query parameters 
Javascript :: bodyparser deprecated vscode 
Javascript :: sequelize init connection set up nodejs node 
Javascript :: get Two digit number js 
Javascript :: how to get decimal value in js 
Javascript :: bootstrap datepicker mindate and maxdate 
Javascript :: laravel json response with error code 
Javascript :: jquery change page on click 
Javascript :: how to get a toggle button to do different js functions 
Javascript :: search functionality in jquery 
Javascript :: jquery dropdown select 
Javascript :: confirm javascript 
Javascript :: How to Use the toLowerCase() String Method in javascript 
Javascript :: puppeeter mac m1 
Javascript :: reset parsley validation 
Javascript :: get closest parent tr table row jquery 
Javascript :: jsx classname multiple 
Javascript :: difference between the `.append()` method and the `.appendChild()` method 
Javascript :: remove classname to node 
Javascript :: javascript append child 
Javascript :: javascript fs read 
Javascript :: how to access router from the store vue 
ADD CONTENT
Topic
Content
Source link
Name
2+5 =