Javascript to extract last parameter of a string after slash(/)

Extract the last parameter of a string which is seperated by a slash using the following line of codes

var str = '';
var n = str.lastIndexOf('/');
var lastParameter = str.substring(n + 1);

here ‘lastParameter‘ will have the value ‘file.png’

Leave a Comment

We would like to show you notifications for the latest offers and updates.
Allow Notifications