Harvey
0
Q:

slice string js

const str = 'The quick brown fox jumps over the lazy dog.';

console.log(str.slice(31));
// expected output: "the lazy dog."

console.log(str.slice(4, 19));
// expected output: "quick brown fox"
5

var str = "Hello world!";

var res = str.slice(0, 5);
 
2
const str = 'The quick brown fox jumps over the lazy dog.';

console.log(str.slice(31)); // expected output: "the lazy dog."

console.log(str.slice(4, 19)); // expected output: "quick brown fox"

console.log(str.slice(-4)); // expected output: "dog."

console.log(str.slice(-9, -5)); // expected output: "lazy"

// source : https://developer.mozilla.org/fr/docs/Web/JavaScript/Reference/Objets_globaux/String/slice
0
var ret = "data-123".replace('data-','');
console.log(ret);   //prints: 123
1

New to Communities?

Join the community