Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why does Chrome debugger skip over delete statements?

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;
})();
like image 528
kenneth koontz Avatar asked Apr 14 '14 22:04

kenneth koontz


1 Answers

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.

like image 136
hyphnKnight Avatar answered Oct 23 '22 19:10

hyphnKnight