DEV Community

sandeepsamanth
sandeepsamanth

Posted on

props-destructuring

const someObject = {
  name: 'john',
  job: 'developer',
  location: 'florida',
};

console.log(someObject.name);
const { name, job } = someObject;
console.log(job);
Enter fullscreen mode Exit fullscreen mode

other ex

const Book = (props) => {
  const { img, title, author } = props;
  return (
    <article className='book'>
      <img src={img} alt={title} />
      <h2>{title}</h2>
      <h4>{author} </h4>
    </article>
  );
};
Enter fullscreen mode Exit fullscreen mode
const Book = ({ img, title, author }) => {
  return (
    <article className='book'>
      <img src={img} alt={title} />
      <h2>{title}</h2>
      <h4>{author} </h4>
    </article>
  );
};
Enter fullscreen mode Exit fullscreen mode

Top comments (0)