Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

javascript split get last element

a = "hello.dear.friends"
a.split(".").pop()
> "friends"
Comment

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/
Comment

PREVIOUS NEXT
Code Example
Javascript :: jquery load 
Javascript :: javascript round to 7 decimal places 
Javascript :: javascript every 
Javascript :: react native password 
Javascript :: discord.js timeout 
Javascript :: Which react-bootstrap component you will use for width: 100% across all viewport and device sizes 
Javascript :: add two numbers in jquery 
Javascript :: javascript check if array 
Javascript :: script src= https//kit.fontawesome.com/a81368914c.js /script 
Javascript :: how to see if checkbox is checked 
Javascript :: jsdoc for express routes 
Javascript :: how to change css variable in javascript 
Javascript :: check if object is not defined js 
Javascript :: my vscode does not recognize react code syntax 
Javascript :: javascript style inline react 
Javascript :: no special characters express validator 
Javascript :: node ssh 
Javascript :: react router active link css 
Javascript :: repeat a function javascript 
Javascript :: the sum of all first n natural numbers js 
Javascript :: variable used in a function can be used in another function js 
Javascript :: string repeat javascript 
Javascript :: js fetch queryselector 
Javascript :: upload files with angular 
Javascript :: js remove key from object 
Javascript :: javascript mod 
Javascript :: get param is react 
Javascript :: react native create text file 
Javascript :: reverse keys and values in object javascript 
Javascript :: checkbox event listeners 
ADD CONTENT
Topic
Content
Source link
Name
8+5 =