DEV Community

Vishnu Priya S
Vishnu Priya S

Posted on

Object destructing , Array destructing

Object destructing

It unpacks the properties from an object and stores the value into new variable in one step

eg: const name = props.name

function child({name}) -- collecting them as a separate variable

so we don't want to call it as repeatly like props.name, props.age props props... with the help of destructing we reduce it.

Array destructing

Similar to Object destructing but the only difference is array are taken by the position.

eg:

const skills = [ "JS" , " React" , "CSS"]

const [skills1, skills2, skills3] = skills
console.log(skills1) //js

Top comments (0)