Last active
February 13, 2019 14:37
-
-
Save ajyounguk/3e49c848ec381e4e07d2b5129b56dd67 to your computer and use it in GitHub Desktop.
object and array splicing / object spread operator (...)
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
messages = { | |
1: { | |
id: '1', | |
text: 'This is a message', | |
userId: '1', | |
}, | |
2: { | |
id: '2', | |
text: 'This is a message too', | |
userId: '2', | |
}, | |
3: { | |
id: '2', | |
text: 'This is a message 3', | |
userId: '3', | |
}, | |
} | |
const { | |
[2]: messsage, | |
...otherMessages | |
} = messages; | |
console.log('... messages ' + JSON.stringify(messages, null, 3)) | |
console.log('... otherMessages ' + JSON.stringify(otherMessages, null, 3)) | |
arr = [ 1,2,3 ] | |
arr.splice(2,1) | |
console.log('splice arr ' + JSON.stringify(arr, null, 3)) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment