Skip to content

Advanced usage

Simon Walters edited this page Aug 18, 2021 · 1 revision

How to implement the shorcut JavaScript method of setting a default value to something that hasn't been set e.g var1 = msg.payload || 'default' type construct

This can be done explicitly by testing if the property exists and then check to see if it is 0, an empty string or boolean false value

but can also be done more compactly by utilising the JavaScript function block