Can we write the code like this in js to check the condition
input != (null || undefined) ? document.write(input) : document.write("Not Found");
I'm expecting to check whether the input is null or undefined
Can we write the code like this in js to check the condition
input != (null || undefined) ? document.write(input) : document.write("Not Found");
I'm expecting to check whether the input is null or undefined
The way you're doing is not right,
input != (null || undefined)
This will always be treated as
input != undefined
because ||
logical OR always returns first truthy value if there's any if not than returns the last value
You can do it either
input != null || input != undefined
or you can
[null,undefined].some(val => val != input)