当前位置:网站首页>TS——枚举
TS——枚举
2022-06-21 10:31:00 【Nanchen_42】
看个例子
enum Language {
java ,
node,
php,
python
}
console.log(Language);
enum枚举
用途:(一般可以做维护使用)
如果一个值未赋值,那么他的上一个值必须是数字,
如果上一个值也是赋值,那么就会获取他的下标,也就是索引
enum Language {
java= 10,
node,
php,
python
}
console.log(Language);
// {10: "java", 11: "node", 12: "php", 13: "python", java: 10, node: 11, php: 12, python: 13}
为什么说他可以做维护呢?看下面这个例子:
通常写的options

这种写法不利于维护,可以写成下面这种写法

打印结果:

边栏推荐
- How to select embedded hands-on projects and embedded open source projects
- Embedded software project process and project startup instructions (example)
- Eureka的TimedSupervisorTask类(自动调节间隔的周期性任务)
- Eureka's timedsupersortask class (periodic task with automatic interval adjustment)
- Telecommuting Market Research Report
- Eig and Saudi Aramco signed a memorandum of understanding to expand energy cooperation
- How to be an interesting person
- Comparison between JWT and session
- On the corners of const
- [cloud based co creation] enterprise digitalization accelerates "new intelligent manufacturing"
猜你喜欢

AI越进化越跟人类大脑像!Meta找到了机器的“前额叶皮层”,AI学者和神经科学家都惊了...

Performance optimization - image compression, loading and format selection

TC software detailed design document (mobile group control)

NLog自定义Target之MQTT
![FastAPI Web框架 [Pydantic]](/img/e1/290a8a6a978b9fb56a9c86f1734c45.png)
FastAPI Web框架 [Pydantic]

Coordinate system transformation, application in inertial navigation antenna

Classification of ram and ROM storage media

Unity中的地平面简介

Running view of program

Why does C throw exceptions when accessing null fields?
随机推荐
Eig and Saudi Aramco signed a memorandum of understanding to expand energy cooperation
Polymorphic & class object & registered factory & Reflection & dynamic proxy
A bit of knowledge - what is amp?
Regression analysis - basic content
从零开始做网站11-博客开发
poi实现操作生成word表格和操作word中的图表数据
Mid 2022 Summary - step by step, step by step
DSP online upgrade (3) -- how to burn two projects in the on-chip flash of a DSP chip
One line of code accelerates sklearn operations thousands of times
How to convert mindspire model to onnx format and use onnxruntime reasoning - development test
程序员新人周一优化一行代码,周三被劝退?
为什么 C# 访问 null 字段会抛异常?
记一次协程环境下类成员变量污染的问题
JWT与Session的比较
ESP8266/ESP32 +1.3“ or 0.96“ IIC OLED指针式时钟
character string
Mythical Games宣布与韩国领先游戏发行商Kakao Games合作,推动亚太区业务扩张
Revenue of Fortinet will increase by 29% in 2021 founder Xieqing talks about the future of network security industry
移动应用开发学习通测试题答案
AI越进化越跟人类大脑像!Meta找到了机器的“前额叶皮层”,AI学者和神经科学家都惊了...