Skip to content

Latest commit

 

History

History
21 lines (15 loc) · 798 Bytes

is_enums_feature_available_in_javascript.md

File metadata and controls

21 lines (15 loc) · 798 Bytes

Is enums feature available in JavaScript?

JavaScript does not have built-in support for enum types like some other programming languages (e.g., TypeScript, C++). However, you can simulate enums in JavaScript using objects or const variables.

Example using an object:

const Colors = {
  RED: 'red',
  GREEN: 'green',
  BLUE: 'blue'
};
console.log(Colors.RED); // 'red'

Alternatively, TypeScript provides a native enum feature.

Tags: intermediate, JavaScript, features

URL: https://www.tiktok.com/@jsmentoring/photo/7464749346089749792