When I am reading official docs, reading/watching recent unofficial guides, etc. I see var
used all over the place inside of function nodes, I very rarely see the use of const
and let
.
It could be due to Node-RED launching prior to ES6, however, in the chance that there could there be an underlying scoping issue that is solved by using var, I need to ask.
Is it safe to use the newer const
and let
variable declarations in Node-RED?
Use the modern const
and let
.
The reason really is that it predates ES6. As to why the community keep making guides with the old var
declaration, it is a mystery.
here is a discussion on Node-RED's board with a similar topic that urges the use of const
and let
.
https://discourse.nodered.org/t/where-to-use-let-and-where-to-use-var-in-a-function-node/33174