String split/join vs Regexp

Edit on GitHub

String split/join vs Regexp

Setup

var id = '9999.0.1';

Tests

  • String split/join

    var new_id = id.split('.').join('_');
  • Regexp

    var new_id = id.replace(/\./g, '_');