简体   繁体   中英

execution of closing bracket of javascript function

When I step over from the return statement at line 12, I go to the } line 14 and not direcly to line 16.

Why is the debugger stopping by line 14 ?

在此处输入图片说明

This is something good from my point of view because it gives you time to have a look at the results within the function. For example, imagine that you have a function with one expression in the body, like this:

function add (a, b) {
  var sum = a + b;
}

The debugger will do a step at the closing brace of the function and you will be able to see the result in the sum. Instead, if the debugger will return immediately, then you will not have the chance to look at the result. Maybe this is a simple example and the value of this feature is not immediately visible but in more complicated cases it is really helpful.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM