const numbers = [1,2,3,4,5] console.log(numbers.slice()) // -> it copies all item console.log(numbers.slice(0)) // -> it copies all item console.log(numbers.slice(0, numbers.length)) // it copies all item console.log(numbers.slice(1,4)) // -> [2,3,4] // it doesn't include the ending position
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter