![]() ![]() Like many other professions, understanding how your tools behave is an important part of software development. Several years ago, I wrote about verifying your tools after a Fiddler visualizer made a debugging session take much longer than it should have taken. Obviously this also serves as a warning against side effects in proxy handlers, but the point here is that these previews can affect the behavior of your code in significant ways. Worse, you could observe the value of a Proxy object without even knowing it might have side effects. Observer effects are especially prominent in physics where observation and uncertainty are fundamental aspects of modern quantum mechanics. This side effect is fairly benign and easy to detect, but imagine a more complex function with multiple dependencies and obscured side-effects. The observer effect is the fact that observing a situation or phenomenon necessarily changes it. Whenever I hover over the code, it re-runs that expression, and the value of i increases. That definition precisely describes the behavior of this Chrome DevTools feature.Ĭonsider the following example where I highlight a call to a function that has a side effect (incrementing the variable i). The observer effect refers to “changes that the act of observation will make on a phenomenon being observed”. This is super useful, but it can also cause problems if you’re not careful about how you use it. ![]() You can check the value of a variable, or even look at the results of more complex expressions. Chrome recently added a new feature to their JavaScript debugger where when you select a piece of code and hover over it, the code is evaluated and displayed in a little popover. ![]()
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |