
- Javascript Basics Tutorial
- Javascript - Home
- Javascript - Overview
- Javascript - Syntax
- Javascript - Enabling
- Javascript - Placement
- Javascript - Variables
- Javascript - Operators
- Javascript - If...Else
- Javascript - Switch Case
- Javascript - While Loop
- Javascript - For Loop
- Javascript - For...in
- Javascript - Loop Control
- Javascript - Functions
- Javascript - Events
- Javascript - Cookies
- Javascript - Page Redirect
- Javascript - Dialog Boxes
- Javascript - Void Keyword
- Javascript - Page Printing
- JavaScript Objects
- Javascript - Objects
- Javascript - Number
- Javascript - Boolean
- Javascript - Strings
- Javascript - Arrays
- Javascript - Date
- Javascript - Math
- Javascript - RegExp
- Javascript - HTML DOM
- JavaScript Advanced
- Javascript - Error Handling
- Javascript - Validations
- Javascript - Animation
- Javascript - Multimedia
- Javascript - Debugging
- Javascript - Image Map
- Javascript - Browsers
- JavaScript Useful Resources
- Javascript - Questions And Answers
- Javascript - Quick Guide
- Javascript - Functions
- Javascript - Resources
Low level difference between Slice and Splice methods in Javascript
The basic difference between slice and splice is −
splice() changes the original array on which it is called and returns the removed item(s) in an array as a new array object.
slice() doesn't change the original array and also returns the array sliced.
Example
// splice changes the array let arr = [1, 2, 3, 4, 5]; console.log(array.splice(2)); //slice doesn't change original one let arr2 = [1, 2, 3, 4, 5]; console.log(array2.slice(2)); console.log("
After Changing the arrays"); console.log(array); console.log(array2);
Output
[ 3, 4, 5 ] [ 3, 4, 5 ]
After Changing the arrays
[[ 1, 2 ] [ 1, 2, 3, 4, 5 ]
- Related Articles
- Difference Between High-Level Language and Low-Level Language
- Difference between shift() and pop() methods in Javascript
- Difference between push() and unshift() methods in javascript
- Difference between test () and exec () methods in Javascript
- What is the difference between functions and methods in JavaScript?
- What is the difference between Math.ceil() and Math.round() methods in JavaScript?
- Difference between system level exception and Application level exception.
- Difference Between First level cache and Second level cache in Hibernate
- Difference between Object level lock and Class level lock in Java
- Difference between Constructors and Methods in Java
- Difference Between Low Flow and High Flow Oxygen
- Python Low-level threading API
- Remove elements from array in JavaScript using includes() and splice()?
- Low-level networking interface in Python (socket)
- Difference between find() and findOne() methods in MongoDB?

Advertisements