Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var a = ['A', 'B', 'C', 'D'];
- var slicedArr = a.slice(1, 3); // slice starts from 1-index to 3-index, but not include 3-index : ['B', 'C']
- console.log(a)
- // ["A", "B", "C", "D"] // slice doesn't change the input
- console.log(slicedArr)
- // ["B", "C"]
- var b = 'ABCD'
- var slicedStr = b.slice(1, 3); // slice process the slice as the array
- console.log(b)
- // "ABCD"
- console.log(slicedStr)
- // "BC"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement