Dealing with Mutable Data

In JavaScript Objects are mutable, which simply means they can be changed. I think the first time I heard this statement I thought “Yeah, so big deal.”. Well, it can be a big deal if you don’t understand what that mutable nature means. It can cause unexpected issues.

In this tutorial that I recently published I talk about the issues you can run into and provide some examples. The examples shows how the mutable nature of objects can cause some unexpected consequences.

I then followed up this tutorial with a second tutorial that shows a possible solution. The solution is cloning objects. This is a technique commonly used in functional programming and is great to be aware of. I think the two tutorials together can be a great help.

What tutorials would you like to see?

Author: Steven Hancock

Steven has 20+ years experience in product development and 15+ years using JavaScript. He started learning JavaScript when it was a niche language used for minor affects on a web site. The growth and ubiquitous nature of JavaScript both excites and inspires him. Currently he is President and lead Trainer at All Things JavaScript, a resource for anyone and everyone that hopes to increase their JavaScript skills. Steven was the co-owner of Rapid Intake, an eLearning Authoring firm. While there he managed all development and professional service related activities. He was heavily involved in the initial development of Rapid Intake's main product, which eventual lead to its acquisition in 2011. In addition to JavaScript, Steve has also dabbled in other web technolgies such as ActionScript, ASP, PHP, HTML, and CSS.