Check for bool is checking for an object instead
I've created this utility method in JS:
function IsAuthenticated(userID)
{
    var isAuthed = false;
    if (userID.length == 0)
        return false;
    // more logic
    if(SomeLogic)
       isAuthed = true;
    return 开发者_运维技巧isAuthed;
}
When I run something like this, I'm getting an object back rather than type bool:
if(IsAuthenticated)
    //code here
I assume I need to cast it to a bool?
IsAuthenticated refers to the function with the name “IsAuthenticated” and is not a function call. If you use the typeof operator on IsAuthenticated you will get "function":
alert(typeof IsAuthenticated);
So try this instead:
var userID = /* … */;
if (IsAuthenticated(userID)) {
    //code here
}
Try return isAuthed instead of just isAuthed.
I think you need:
return isAuthed;
 
         加载中,请稍侯......
 加载中,请稍侯......
      
精彩评论