You are reading a single comment by @NebbishHacker and its replies. Click here to read the full conversation.
  • In theory you could avoid some of the memory overhead of the array returned by match() by instead using replace to generate a new string that contains only the newlines:

    s.replace(/[^\n]/g, "").length
    

    Unfortunately, there seems to be a bug in replace() that prevents this from working perfectly.

About