here is javascript code:
var test = {
"h" : function (a) {return a;},
"say" : "hello"
};
First run:
test['h'] && true
result is true
second run :
true && test['h']
result is function()
my question is, why first run and second run produce different result
The last truthy argument of
&&is returned. (If there is a non-truthy argument, false is returned, of course.) That’s just how&&works.