Created
July 13, 2017 18:26
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!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