Grateful Grateful - 1 year ago 76
AngularJS Question

Why `auth.logout && auth.logout();` in the following example?

I am looking at the angular authentication application at But I don't understand what is happening with the statement

auth.logout && auth.logout();
on line 102 of the js file. Why does it appear to be calling

Any hints?

Answer Source

I'm not familiar with Angular, but in JavaScript the first auth.logout doesn't actually call the function. It will return the function itself, making sure that the function only gets called (the second auth.logout()) if it actually exists.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download