Compile regexp and assign to var vs Assign to var

Edit on GitHub

Benchmark regexp compilation

Setup

Tests

  • Compile regexp and assign to var

    var test = /^foo:\/\/(.+?)\//;
  • Assign to var

    var test = "";