how to get substring after character in javascript code example

Example 1: get string after character javascript

const str = '01-01-2020';

// get everything after first dash
const slug = str.substring(str.indexOf('-') + 1); // 01-2020

// get everything after last dash 
const slug = str.split('-').pop(); // 2020

Example 2: get everything after the first character javascript

var val = 'asdasd:111122:123123123';
var response = val.substring(val.indexOf(":"));

alert(response); // ":111122:123123123"

Example 3: javascript substring after character

// function you can use:
function getSecondPart(str) {
    return str.split('-')[1];
}
// use the function:
alert(getSecondPart("sometext-20202"));

Example 4: javascript substring after character

var testStr = "sometext-20202"
var splitStr = testStr.substring(testStr.indexOf('-') + 1);