Kaine Bruce
Projects Blog About

All Blogs tagged with: Javascript

JavaScript: The Spread operator can be destructive.

While learning React, I was taught to use the spread operator to copy an array. This is not always a good idea.

Posted on Tuesday, April 12, 2022 @ 08:59 AM UTC by Kaine

Tags:

  • JavaScript
  • React
When updating the state in React I was taught to first copy the objects using the spread operator. However, this doesn't actually copy the objects, it just copies the reference of the object. ie, it's the same object! If you're unaware of it, this could catch you off guard.
» Continue Reading »

Recent Posts

  • Welcome to the site!
    Mon, Jan 16, 2023
  • JavaScript: The Spread operator can be destructive.
    Tue, Apr 12, 2022

Tags

  • Blog 1 Post
  • JavaScript 1 Post
  • React 1 Post
To the Top
  • Home
  • Projects
  • Blog
  • About

Kaine Bruce @ 2023