Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

js enums class

class Enum {
  constructor(...keys) {
    keys.forEach((key, i) => {
      this[key] = i;
    });
    Object.freeze(this);
  }

  *[Symbol.iterator]() {
    for (let key of Object.keys(this)) yield key;
  }
}

const daysEnum = new Enum(
  'monday',
  'tuesday',
  'wednesday',
  'thursday',
  'friday',
  'saturday',
  'sunday'
);

const days = [...daysEnum]; // Array of the enum values as strings
Comment

PREVIOUS NEXT
Code Example
Javascript :: angular filter ngfor 
Javascript :: jquery growl cdn 
Javascript :: express redirect 
Javascript :: convert file to blob in angular 
Javascript :: React Hook "React.useState" is called in function "placeItem" which is neither a React function component or a custom React Hook function react-hooks/rules-of-hooks 
Javascript :: Rename files in a directory with node.js 
Javascript :: how to append values to dropdown using jquery 
Javascript :: js array set value at index 
Javascript :: select2 clear fields 
Javascript :: remove duplicate items from array 
Javascript :: lodash remove element from list 
Javascript :: javascript base 10 to base 2 
Javascript :: typeorm where in 
Javascript :: DragDropContext 
Javascript :: javascript to remove duplicates from an array 
Javascript :: getting current date and time in javascript 
Javascript :: local storage remove multiple items 
Javascript :: moment cdn 
Javascript :: heroku scripts 
Javascript :: shadow using react native 
Javascript :: add event listener in react useeffect 
Javascript :: javascript regex replace 
Javascript :: jquery duplicate last table row 
Javascript :: javascript get sum array values 
Javascript :: jquery validation manually trigger 
Javascript :: javascript array of zeros 
Javascript :: javascript array to object with keys 
Javascript :: js get random from array 
Javascript :: vite.config.js 
Javascript :: remove url from string javascript 
ADD CONTENT
Topic
Content
Source link
Name
4+5 =