This discussion was interesting but I have not been able to find something that's really going to work for me as I really just want to return true
or false
on an object's existence. I also really dislike verbose code and am looking for a simple and easy way to write things with minimum fuss.
For example it's suposed to be defined like this: Bigobject.option
but that may not yet exist.
So I came up with this:
(!Bigobject.option == false)
, and this returns false
if option
isn't yet in existence, and true
if it has been set to anything, including "nothing" or an empty string, object or array.
What I'd like to understand:
Is this a weird way to do it? Is it "legal"? Is this going to work consistently? Am I supposed to do it differently? Thanks for the help.