let string = 'foo_bar'; string = string.slice(-4, 0); // Slice off last four characters here console.log(string); Run code snippetHide results