Cara menghapus teks dari string di javscript
var ret = "data-123".replace('data-','');
console.log(ret); //prints: 123
Mobile Star
var ret = "data-123".replace('data-','');
console.log(ret); //prints: 123
const string = "0123456789";
console.log(string.slice(0, 2)); // "01"
console.log(string.slice(0, 8)); // "01234567"
console.log(string.slice(3, 7)); // "3456"
let str = "12345.00";
str = str.substring(0, str.length - 1);
console.log(str);
Run code snippetHide results