JavaScript Handling Errors

Rebecca Palumbo
Rebecca Palumbo
5,271 Points

How is it that you can call a function into a then handler without an argument or parentheses?

But then you put an argument in the function? I'm confused. I'm referring to the checkStatus function here.

1 Answer

Steven Parker
Steven Parker
177,509 Points

When you set up a handler, one of the arguments is a function. But you don't want to call the function at that point, you only want to pass a reference to the function so the handler can call it when the event occurs.

That's why when you use a named function as a callback argument you don't put parentheses after the name.