Tell us what’s happening:
Why does setting the object[index] == true return falsy, while leaving out the equality return truthy? Shouldn’t they mean the same thing?
even if you just pass an empty object in an if condition it will always return true.
In your case obj[pre] == true here the value of obj[pre] is matched with true and returns true only if the obj[pre] == true
whereas if you just pass an object in if condition it will give you true except if it is undefined, null , ‘’, and there might be some more you need to watch out for
someVariable === true will return true if and only if the value of someVariable is the boolean value true. someVariable === false will return true if and only if the value of someVariable is the boolean value false.
If you just put someVariable in a logical operation (like an if statement) then it will be evaluated for “truthiness” or “falsyness”.