can someone explain me why my code isn’t working as I want to?
test = function(argument){
var arg = argument || true;
console.log(arg)
};
test(false);
and return is always true. I thought that it will only be true if argument is 'undefined'?
thanks for answers! 🙂
||is the logical or operator. Sofalse OR trueevaluates totrue.undefinedisfalseyas well, so its a short hand for returning the right-hand side of the operator.You might want this instead