Skip to content

Instantly share code, notes, and snippets.

@zachfedor
Created July 13, 2017 18:26
Show Gist options
  • Save zachfedor/ec4e8054a6a3bd70f238857e93e79bf8 to your computer and use it in GitHub Desktop.
Save zachfedor/ec4e8054a6a3bd70f238857e93e79bf8 to your computer and use it in GitHub Desktop.
Demo to show mutations of nested objects logged to Chrome's Developer Console
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>buggy html</title>
<script>
const object = { nested: { state: 'before' } };
// create a nested object
console.log(object);
// output to dev console
debugger;
// inspect object.nested.state, see 'before'
// continue the script through the breakpoint
object.nested = { state: 'after' };
// look at console again, still see 'before'
// even though the nested object has been mutated
// refresh the page but don't look at the object
// in the console until after continuing through
// the breakpoint. see 'after'
</script>
</head>
<body>
open the dev console
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment