-2

I got the following string from a Json:

image/folder/folder/xxx.jpg

I would like to explode the xxx.jpg and keep it to local var.

thanks

Scopi
  • 663
  • 1
  • 5
  • 20

1 Answers1

0

Split it using String#split method and get the last value from the array using Array#pop method.

var string = " image/folder/folder/xxx.jpg";

var res = string.split('/').pop();

console.log(res);
Pranav C Balan
  • 110,383
  • 23
  • 155
  • 178