Skip to content

re: Pro Tip: How to find the accidental mutation VIEW POST


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