nzakas / understandinges6

Content for the ebook "Understanding ECMAScript 6"
5.45k stars 796 forks source link

Symbol.split example with limit optional argument #470

Open ronen-e opened 1 year ago

ronen-e commented 1 year ago

The example for Symbol.split here manuscript/06-Symbols.md does not mention the optional limit argument:

split(separator)
split(separator, limit)

The current example could perhaps change to

[Symbol.split]: function(value, limit) {
  return value.length === 10 ? ["", ""] : [value];
}

Or perhaps change this text:

Symbol.split - A function that accepts a string argument and returns an array containing pieces of the string split on the match.

To this:

Symbol.split - A function that accepts a string argument and an optional limit argument, and returns an array containing pieces of the string split on the match.

nzakas commented 1 year ago

Ah thanks. Because this book is so old, I wasn't planning on updating it again unless the publisher does another printing. I'll leave this open to remind myself if that happens.