ES6 came with plenty of cool features. Destructuring is one of them. It became so easy to unpack values from arrays, or properties from objects and assign them to a specific variable.
Previously, we had to do this : π
var stack = ["JavaScript", "React", "Redux"]
var language = stack[0] // JavaScript
var library = stack[1] // React
var stateManagement = stack[2] // Redux
But with ES6 we can easily destrucutre them like this : π
const stack = ["JavaScript", "React", "Redux"]
const [language, library, stateManagement] = stack
Now, we can leverage this to destructure anything that returns an array : π€
const stack = "JavaScript-React-Redux"
const [language, library, stateManagement] = stack.split("-")