Page 1 of 1

How to check a variable is undefined

Posted: Wed Sep 13, 2017 3:40 pm
by henry
How to check a variable is undefined in compare variables module?
We tried the undefined, 'undefined' and '', all the choices do not works.
Any suggestions?

Re: How to check a variable is undefined

Posted: Wed Sep 13, 2017 4:48 pm
by support
The compare variables module interprets data as strings. If you wish to check for a undefined variable in Javascript, you will have to use the Evaluate JS module with code like:

Code: Select all

if ([variable] === undefined) { [variable] = 'undefined'; }
Then you can check the variable with the compare variables module, since you have changed its value to the string "undefined".

However, it is not good coding convention to intentionally send undefined variables, so we would recommend rethinking your application to not rely on undefined variables.