9

Why does the Chrome debugger skip over delete statements? The following code will demonstrate the observation if ran in a console.

(function () {
  var foo = { bar: true };
  debugger;
  delete foo.bar;
})();
kenneth koontz
  • 849
  • 1
  • 8
  • 16
  • 1
    This is so weird I never noticed it before. It does go over a statement which creates an object var foo = {} so it only makes sense that it should go over delete statement as well. Couldn't find any explanation anywhere though. – sublime Apr 15 '14 at 00:25
  • 2
    Someone had previously [filed a bug](https://code.google.com/p/v8/issues/detail?id=2957) with V8, though there hasn't been any response to it. – Qantas 94 Heavy Apr 19 '14 at 12:03
  • 2
    Check out [this](http://perfectionkills.com/understanding-delete/#delete_and_host_objects) algorithm for `delete`. Interestingly, the debugger does stop for some of the other scenarios of delete (such as `delete foo`). – 0not May 29 '14 at 19:19

1 Answers1

1

The answer here is in the nature of the command 'delete' its not a common function as you are used to in js. My guess is that the chrome tools are set to stop on every line that contains an object definition or an object running a method, behind the scenes almost everything one encounters in javascript is an object, however delete is not am object but an operator like '+' or '-'. And the reason it gets skipped is because this will be the only time you will have a line that doesn't throw a error but does not define or call an object.

hyphnKnight
  • 303
  • 2
  • 6