Last active
September 19, 2017 15:24
-
-
Save nire0510/1383f1424512a4fde37d0ad7a261d5e6 to your computer and use it in GitHub Desktop.
[Splice vs. Slice] #javascript
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let a = [1, 2, 3, 4, 5, 6]; | |
let b = [1, 2, 3, 4, 5, 6]; | |
console.log('-- SLICE --'); | |
console.log('- Returns values which were removed'); | |
console.log('- Does not change the original array'); | |
console.log(a.slice(0, 2)); | |
console.log(a); | |
console.log(); | |
console.log('-- SPLICE --'); | |
console.log('- Returns values which were removed'); | |
console.log('- Changes the original array'); | |
console.log(b.splice(0, 2)); | |
console.log(b); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment