You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
"Why we invented String.p.split like that" was asked in the meeting. So I suppose there are also people interest in this topic. Maybe it could be added to README.
When we have JSCIG meeting last week, the same question is asked and @aimingoo did a quick research, here is the info:
ES1 (1997/6) and ES2 do not have split with the second arg
ES3 add it
And I did some test:
NN3(1996/8) do not have second arg
NN4(1997/6) has it
IE4(1997/10) do not have it
So my conclusion is:
The second arg was added by Netscape in some point from 1996/8 to 1997/6.
This API is not from Java, because Java only add String.split in 1.4 (2002)
It seems TC39 just added it to ES3 as NN4 behavior.
The text was updated successfully, but these errors were encountered:
Today I happened to read some code of old netscape navigator, and as the code and comments tell, js split is definitely coming from Perl. But Brendan just implemented the simplest version (split(string)) in the beginning.
JavaScript 1.2 added regexp and follow the re capture as Perl, and even some special perl behavior: " a b c ".split(' ') would return ['a', 'b', 'c'] (behave like .trim().split(/\s+/)). So I believe the plan was also implement the limit param just as perl. The old "New in JS 1.2" documentation even said:
It can take a limit count so that it won't include trailing empty elements in the resulting array.
The sentence only make sense if follow perl behavior (when limit is omit or 0, strip empty elements).
Unfortunately, for unknown reason (may be no enough time, or just forgot), netscape engineers didn't fully implement it...
"Why we invented String.p.split like that" was asked in the meeting. So I suppose there are also people interest in this topic. Maybe it could be added to README.
When we have JSCIG meeting last week, the same question is asked and @aimingoo did a quick research, here is the info:
And I did some test:
So my conclusion is:
The text was updated successfully, but these errors were encountered: