Skip to main content
fixed first -> second
Source Link
PleaseStand
  • 32.2k
  • 7
  • 72
  • 96

The difference is that in the secondfirst example, successFn will not get the callback function arguments. Neither will the this object be the same; in fact, it will be window rather than whatever may be specified as the context for the .ajax() call if the function is not a member of an object (in xyz.successFn(), this would be xyz).

The secondfirst approach is less concise and possibly slower; by "wrapping" the function, you are quite possibly using more browser memory and CPU time. I wouldn't use the secondfirst approach unless you are paid by the line of code or you need this to point to an object that successFn is a member of.

The difference is that in the second example, successFn will not get the callback function arguments. Neither will the this object be the same; in fact, it will be window rather than whatever may be specified as the context for the .ajax() call if the function is not a member of an object (in xyz.successFn(), this would be xyz).

The second approach is less concise and possibly slower; by "wrapping" the function, you are quite possibly using more browser memory and CPU time. I wouldn't use the second approach unless you are paid by the line of code or you need this to point to an object that successFn is a member of.

The difference is that in the first example, successFn will not get the callback function arguments. Neither will the this object be the same; in fact, it will be window rather than whatever may be specified as the context for the .ajax() call if the function is not a member of an object (in xyz.successFn(), this would be xyz).

The first approach is less concise and possibly slower; by "wrapping" the function, you are quite possibly using more browser memory and CPU time. I wouldn't use the first approach unless you are paid by the line of code or you need this to point to an object that successFn is a member of.

Source Link
PleaseStand
  • 32.2k
  • 7
  • 72
  • 96

The difference is that in the second example, successFn will not get the callback function arguments. Neither will the this object be the same; in fact, it will be window rather than whatever may be specified as the context for the .ajax() call if the function is not a member of an object (in xyz.successFn(), this would be xyz).

The second approach is less concise and possibly slower; by "wrapping" the function, you are quite possibly using more browser memory and CPU time. I wouldn't use the second approach unless you are paid by the line of code or you need this to point to an object that successFn is a member of.