C-Sharp | Java | Python | Swift | GO | WPF | Ruby | Scala | F# | JavaScript | SQL | PHP | Angular | HTML
JavaScript TypedArray slice() MethodThe JavaScript slice() method gives the selected elements of the array on which it is implemented. The original array remains unchanged. Syntax:Array.slice(start, end) Parameters:Start(Optional): Starting position where to start the selection. End(Optional): Ending position where to end the selection. Return value: Returns a new array that contains some selected part of the array. Browser Support:
ExampleJavaScript TypedArray slice() Method. <script> //JavaScript to illustrate slice() method function JavaTpoint() { //Original Array var arr = [12,34,56,67,44,33,4,55]; //Extracted array var new_arr = arr.slice(2 ); document.write("without using slice() method <br>"); document.write(arr); document.write("<br>"); document.write("using slice() method <br>"); document.write(new_arr); // expected output:56,67,44,33,4,55 } JavaTpoint(); </script> Output: 56,67,44,33,4,5
Next TopicJavaScript TypedArray Object
|