I was hovering over a link recently and saw one with an href of javascript:void[0]. This was pretty surprising, since it’s usually written as javascript:void(0). Granted, the whole thing is supposed to imply meaningless anyway, but I wonder what led someone to use this variant.

Makes me wonder if void 0 would cause some sort of issue with spaces and URI encodings, or if void(0) was popularized because it looks like a function call even though it isn’t.

I’m feeling confident that they wanted void(0) but just typed it wrong or didn’t know any better.

I always thought void(…) was preferred because you could add multiple expressions in there rather than just the 0 if you wanted. Though I have done this before, I’d also guess no one else probably does it and probably sticks to void 0 because its the thing they’ve read to do, and probably using the format void(0). So who was the first person to suggest this and how did they present it? MDN currently references it as void(0). Maybe there is some weird legacy encoding thing involved with that…? I’m too lazy to look into it further :stuck_out_tongue_winking_eye:

I never thought about using anything but void(0). Whoever came up with that decades earlier probably didn’t have a good reason either and is probably having a good chuckle at all of us trying to find the hidden meaning behind it :stuck_out_tongue: