Call to a JS function
alertStatement()
Function Definition
function alertStatement(link) {
if (link) {
alert('A');
}
if (link!=null) {
alert('B');
}
}
Both of these statements are working fine in Windows Env with Tomcat, but none of them execute it on production (Linux server). Is there any other way to compare variables to make it working?
I got it working using the following javascript code.
function alertStatement(link) {
if (link!==undefined){
alert('A');
}
}
So at last undefined worked for me , for some reason null comparison didn’t work
To see if the argument has a usable value, just check if the argument is undefined. This serves two purposes. It checks not only if something was passed, but also if it has a usable value:
Some people prefer to use typeof like this:
nullis a specific value.undefinedis what it will be if it is not passed.If you just want to know if anything was passed or not and don’t care what its value is, you can use
arguments.length.