... until the collector arrives ...

This "blog" is really just a scratchpad of mine. There is not much of general interest here. Most of the content is scribbled down "live" as I discover things I want to remember. I rarely go back to correct mistakes in older entries. You have been warned :)

2006-10-10

Javascript Split Function

I discovered a discrepency in the way that the Microsoft and Mozilla implementations of Javascript handle the 'split' function.  Consider this expression:

"!abc!def!ghi!".split(/!/)

Mozilla returns an array with five elements, the first and last elements being empty strings.  Microsoft returns only three elements, having dropped the first and last elements.  Intuitively, Mozilla seems correct.  The definition of split in the ECMA-262 standard is difficult to read, but appears to support Microsoft's interpretation.

Blog Archive