It took me a few minutes to sort this one out. The code in my (demo)
function node is:
var node = 'hello world';
The third line throws an error, "TypeError: node.warn is not a function"
I guess it's clear what is happening. There probably is no need for a warning in the documentation, unless there are other keywords that should be avoided. (I haven't had time to think about it.)
I beleive I bumped into this at one point and spent some time pulling my hair out
You might want to avoid
RED as well
I'd suggest avoiding everything we document as being already-defined in the Function node - https://nodered.org/docs/user-guide/writing-functions#api-reference
Sorry but this is pure JS .... Node-RED exposes a variable/object named "node"... if you redefine it as a string, of course the original functions/methods/properties will be deleted and it won't work ...
Also do not redefine
undefined and many others...
Well yes, that's why I said it's clear what's happening, but no it's also a Node-RED issue since it was not obvious to me exactly what objects are exposed in the
function node sandbox. The page @knolleary linked is helpful, assuming it is complete and stable.
This may confuse some folks. "
undefined and many others" presumably refers to JS reserved names. On the other hand,
RED is a NR-defined object, and as far as I can see from the documentation, the only others like it are
global. Please let me know if I have missed something.
The link I gave you lists all of the pre-defined variables within the Function node.
I think it is reasonable for you to assume it is complete and stable.
Thanks! I didn't mean to imply otherwise.