A (Trivial) Mistake in the MDN Web Docs?

For the Javascript function String.prototype.split(), the MDN web docs give the following interface:

str.split([separator[, limit]])

Curiously, they also make the following claim:

Screenshot from MDN reference for optional limit argument

Notice in particular the center bullet: if limit is 1, str.split(separator)[0] is returned. I know Javascript has a messed-up type system, but this does seem to be a “type error.”1 Indeed, you can try the following in the console of any browser:

"Hello World!".split(" ", 1);  // ["Hello"]
"Hello World!".split(" ")[0];  // "Hello"

This is clearly just a silly typo, but it’s always neat to spot one out in the wild. I’ve archived a version of the original page that has this text.


Update: I made an issue in the MDN Github repository, but apparently it’s already been fixed. Loading the page now shows that it is indeed correct. Well, one day I’ll find a typo that no one has found before. If I’m lucky, it’ll be in one of Knuth’s books!


  1. No clue why I’m bringing this up, but talking about types, particularly lists and singletons, brings to mind something cute I once saw on Math Overflow. Can you come up with sets AA and BB such that ABA \subseteq B and ABA \in B are both true?↩︎


Comments

Submit a comment

Your comment will be held for moderation. If needed, I'll reach out to the provided email address with moderation updates. Your email will not be publicly displayed.

Note: comments are still in beta. Let me know if anything is broken!