Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

javascript split remove last element

let path = "/bar/foo/moo/";
let split = path.split("/");
let splicedStr = split.slice(0, split.length - 2).join("/") + "/";
console.log(splicedStr);
//outputs:  /bar/foo/
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #javascript #split #remove #element
ADD COMMENT
Topic
Name
7+9 =