Skip to content

Pro Tip: How to find the accidental mutation

Hussein Duvigneau on June 27, 2018

I joined a React project with no immutability library or middleware, but it's too far-gone to make that change now, especially considering it's nev... [Read Full]
markdown guide

You can also use setters to figure out where a mutation on a specific property is coming from:

var person = { name: 'foobar' };

var name =;
Object.defineProperty(person, 'name', {
  set(value) {
    console.trace('Changing to value: %s', value);
    name = value;
  get() {
    return name;

This way you don't need to put use strict everywhere to find the culprit.

code of conduct - report abuse