+ 1
What is the difference between substring(), substr() and slice() in Javascript?
Can anyone explain this with an example or preferably a code?
1 Odpowiedź
+ 2
substring take start index and end index
substr take start index and length
slice same as substring with abit different behavior
ex
let x="Hello"
x.substring(1,3) //el
x.substr(1,3) //ell
//slice can take negative value as end index
x.slice(1,-3) //e