10 examples of 'jquery remove last character' in JavaScript

Every line of 'jquery remove last character' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your JavaScript code is secure.

All examples are scanned by Snyk Code

By copying the Snyk Code Snippets you agree to
this disclaimer
48deleteLastChar() {
49 var lastString = this.strings_.length - 1;
50 var last = this.strings_[lastString];
51 if (last) {
52 this.strings_[lastString] = last.slice(0, -1);
53 }
54}
Important

Use secure code every time

Secure your code as it's written. Use Snyk Code to scan source code in minutes – no build needed – and fix issues immediately. Enable Snyk Code

140function replaceLastCharacter(string, character) {
141 return string.slice(0, string.length - 1) + character;
142}
155function removeFirstWord(str, word) {
156 if (word === void 0) { word = ""; }
157 if (!word) {
158 word = getFirstWord(str);
159 }
160 var index = str.indexOf(word);
161 if (index == -1)
162 return str;
163 return str.substring(index + word.length);
164}
85function removeEndsChar(str, char) {
86 if (typeof str !== 'string') return '';
87
88 return str.endsWith(char) ? str.slice(0, -1) : str;
89}
40function appendLast(row: string, char: string) {
41 const last = row[row.length - 1];
42
43 if (last !== char) {
44 return row + char;
45 } else {
46 return row;
47 }
48}
47function deleteChar(input) {
48 input.value = input.value.substring(0, input.value.length - 1)
49}
69function rmTrailingChar(str, c) {
70 if (str.slice(-1)[0] === c) return str.slice(0, -1);
71 else return str;
72}
37function lastNonWhitespace() {
38 var p = chars.length - 1;
39
40 while (p >= 0) {
41 var pp = chars[p];
42 if (pp !== ' ' && pp !== '\n' && pp !== '\r' && pp !== '\t') { // non whitespace
43 return pp;
44 }
45 p--;
46 }
47
48 return '';
49}
230export function getLastVariable(str) {
231 str = str.trim();
232 var word = "";
233 for (var i = str.length - 1; i >= 0; i--) {
234 var char = str.charAt(i);
235 if (isVariableChar(char)) {
236 word = char + word;
237 } else {
238 break;
239 }
240 }
241 return word.trim();
242}
4function trim(s)
5{
6 return trimRight(trimLeft(s));
7}

Related snippets