substring vs slice

Edit on GitHub

Setup

Tests

  • substring

    var a = 'I love Javascript!';
    a.substr(0, 5);
  • slice

    var a = 'I love Javascript!';
    a.slice(0, 5);