slice in js/programiz code example
Example 1: slice in javascript
JavaScript Array slice() Method The slice() method returns the selected elements in an array, as a new array object. The slice() method selects the elements starting at the given start argument, and ends at, but does not include, the given end argument. Note: The original array will not be changed.
Example 2: slice in js
//The slice() method extracts a section of a string and returns
//it as a new string, without modifying the original string.