jeudi 29 janvier 2015

JavaScript condition always fails

In the below code, the if statement always fails. New to JavaScript, couldn't figure out.


I believe the code is self explanatory. What am I doing wrong?



if (localStorage.user_name === null || localStorage.user_name === 'undefined') {
registerUser(userName);
} else {
login(localStorage.user_name); // Gets executed always... Even if there is no user_name in localStorage.
}

Aucun commentaire:

Enregistrer un commentaire