For context you can find the full class definition @ https://github.com/getify/You-Dont-Know-JS/blob/master/this%20%26%20object%20prototypes/ch6.md
I am trying to understand this particular expression found under "Simpler Design"
LoginController.prototype.validateEntry = function(user,pw) {
user = user || this.getUser(); //this is the statement I can't follow
pw = pw || this.getPassword();
If user = undefined
or user = ""
, then user = user //false
. For any string values user = user //true
. But in these cases user = user;
evaluates to the same value as simply user;
1) is there any added functionality by writing user = user;
instead of just user
;?
2) why is the JavaScript engine able to evaluate a LHS assignment as a boolean value?