What is happening in ‘+!+char’? Are either of those ‘+’ adding something, or are they both acting as unary operators? I know the ‘!’ is ‘not’, but I’m not understanding the combination of those characters. I did noodle around with it, and could see that if fed a ‘1’, it returns ‘0’ , and vice versa. I guess what I want is a ELI5 for what is happening as the computer looks at those characters.
That is just about exactly what I needed, thank you! I hadn’t thought of deconstructing it in that fashion. I’ve been studying JS for about 6 months now, and every time I think I have a handle on the truthy/falsy concepts, I encounter something like this that just looks like witchcraft
Agreed. In the first few months I was coding, that’s what I thought was good, that shortest meant best. I’ve since talked with a lot of people in the industry who are quick to point out that code golf is NOT the way in the real world!