It's common to see code in the form of if (false == true). We get a fair bit of it in our inbox, and we generally don't post it often, because, well, it's usually just a sign that someone generated the code. There's a WTF in that, somewhere, but there's not much to say about the code, beyond, "Don't generate code, pass data from backend to frontend instead."

But Nicholas sends us one that shows a little more of interest in it.

if ('N' == 'Y') {
 document.getElementById("USERID").disabled=true;
 document.getElementById("PASSWORD").disabled=true;
}

Again, this is almost certainly being generated by the backend and sent to the frontend. I mean, it might be someone manually disabling a block of code by writing an if that'll never be true, but probably not in this case.

And what this tells us is that the backend is getting inputs, probaly from some sort of option field, and treating them as booleans. Y and N are clearly meant to be "yes" and "no", aka "true" and "false", but we're taking the stringly typed approach on the backend.

For future developers, I reiterate: send data to the frontend, so your 'if' looks more like: if(backendData.userSelectedOption=="Y"), or at the very least if you're going to evaluate the boolean expression, evaluate it on the backend, so the generated code is just if(false).

[Advertisement] BuildMaster allows you to create a self-service release management platform that allows different teams to manage their applications. Explore how!