const anotherUnneededNonCapture = /lab(?:o)rum/
const anotherNoNonCapture = /laborum/
As far as V8 goes, the reason for the difference has to do with an "optimization" that occurs when the regexp literal is just a plain string. In those cases, a simple string search is done (e.g. an implicit
loremString.indexOf('laborum')) whereas this change in behavior is skipped if there are any special regexp characters in the regexp string.
/lab(?:o)rum/ is actually going through the regexp engine and
/laborum/ implicitly goes through an
You can see this when profiling the code from node with the
--prof and then afterward with
--prof-process command-line options.