Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

remove suffix string js

let text = 'ABCD';

// replace the last two characters with empty string
let result1 = text.replace(/.{0,2}$/, '');

// remove the last two characters
let result2 = text.slice(0, -2);

// remove the last two characters
let result3 = text.substring(0, text.length - 2);

console.log(result1);  // AB
console.log(result2);  // AB
console.log(result3);  // AB
Comment

PREVIOUS NEXT
Code Example
Javascript :: copy object with new property in js 
Javascript :: google autocomplete not returning lat long 
Javascript :: change inptu val 
Javascript :: react native google places autocomplete 
Javascript :: use filereader javascript 
Javascript :: optional function parameter javascript 
Javascript :: check if form bootstrap is valid js 
Javascript :: javascript good practice 
Javascript :: getdata from fetch api into variable 
Javascript :: console.log() Print a Sentence 
Javascript :: remove an last item of array in javascript 
Javascript :: add 
Javascript :: how to make an array of a value from 1 to the number 
Javascript :: mongoose updatemany example 
Javascript :: sort array of numbers 
Javascript :: animate change of class angular 
Javascript :: db.json code 
Javascript :: js string to int 
Javascript :: pdfjs get all the text present 
Javascript :: template literal syntax 
Javascript :: how to pick date from datepicker in selenium 
Javascript :: value of javascript 
Javascript :: new array from javascript 
Javascript :: react-data-table-component cell action stack overflow 
Javascript :: remove object from array javascript 
Javascript :: object comparison in javascript 
Javascript :: setCenter: not a LatLng or LatLngLiteral with finite coordinates: in property lat: not a number 
Javascript :: nodejs express flash message 
Javascript :: javascript loop counter 
Javascript :: latecy discord 
ADD CONTENT
Topic
Content
Source link
Name
8+9 =