using javascript
I have a function
function test(variable)
{
if(variable != 'undefined')
{
console.log('variable is not set');
console.log('variable', where);
}
}
i call it using test();
yet in the console I get
‘where is not set’
‘where is set as undefined’
why?
Update
This function is not what i am actually using.
The function should not do anything if the variable is undefined.
the example was to show the if statement not working.
But the issue was actually me using if variable != 'undefined' instead of variable != undefined
You are testing whether
variablehas the string content of"undefined".What you probably want is
The rest of the function is not making sense to me yet, either. Where does
wherecome from?