How to create enum global

I am new to node-Red so I do not know if there is an enum in Node-Red?
If has, can I set it to enum global so that multiple nodes can use it?
or how does Node-Red use enum type, please suggest for me!
Thanks in advance.

This is not a Node-RED question really, rather a JavaScript one.

JavaScript doesn't really have ENUM's mainly because it isn't a typed language. But also because you can so easily create objects with properties.

If you really want ENUM's, you could need to switch to Typescript but that means that you need to compile all of your code to JavaScript before you can use it.

Otherwise, the JS way would be to build a reference object variable containing either a list of valid entries or an Object of key'd entries depending on need.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.