Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

string remove last character

public static String removeLastCharacter(String str) {   
	String result = null;   
    if ((str != null) && (str.length() > 0)) {      
    	result = str.substring(0, str.length() - 1);   
    }   
    
    return result;
}
Comment

Remove the last character from String using Slice

const bookName = 'Atomic Habits' // 13 characters (indexes between 0 and 12)
const newBookName = bookName.slice(0, bookName.length - 1) // Between (0 and 12)

console.log(newBookName)
// Output: "Atomic Habit"
Comment

PREVIOUS NEXT
Code Example
Javascript :: javascript function loop through array 
Javascript :: jquery click 
Javascript :: js get substring before character 
Javascript :: react conditionally disable button 
Javascript :: add multiple event listeners 
Javascript :: union of two arrays javascript 
Javascript :: javascript string in string 
Javascript :: Date gethours js 
Javascript :: how to clone array in js 
Javascript :: javascript mousedown mouseup 
Javascript :: canvas js filter greyscale 
Javascript :: nuxt progress false 
Javascript :: Check if user logged in Wordpress through JS 
Javascript :: preventdefault not working react 
Javascript :: extract payload of expired jwt token in js 
Javascript :: Not allowed to navigate top frame to data URL 
Javascript :: javascript code 
Javascript :: how to change color on js 
Javascript :: javascript get element by rel attribute 
Javascript :: avoid no-param-reassign when setting a property 
Javascript :: manifest.json basic structure 
Javascript :: javascript play pause button 
Javascript :: validate password with 8 Characters, One Uppercase, One Lowercase, One Number and One Special Case Character 
Javascript :: react.fragment react native 
Javascript :: how to get array from number length 
Javascript :: split string based on length in javascript 
Javascript :: remove duplicated from array of ojects 
Javascript :: add query parameter to url react router v6 
Javascript :: angular bind style value 
Javascript :: urlencoded limit 
ADD CONTENT
Topic
Content
Source link
Name
7+1 =