Grateful Grateful - 2 months ago 8
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?


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.