I'm interested in "HOW it work" knowledge for JavaScript binary logical operations, but I'm stuck at step interpritation.
So that's description of specs
12.13.3
LogicalANDExpression: LogicalANDExpression && BitwiseORExpression
- Let lref be the result of evaluating LogicalANDExpression.
- Let lval be ? GetValue(lref).
- Let lbool be ToBoolean(lval).
- If lbool is false, return lval.
- Let rref be the result of evaluating BitwiseORExpression.
- Return ? GetValue(rref).
And i read this like:
Take memory for left operand and here will be operation result
Get value of left operand in memory and convert it to boolean
if this boolean is false, return left operand
Else take memory for right operand and here will be... BitwiseORExpression <-- what? Bitwise? for what? why?
I'd would like to clarify this algorithm in more human-readable form for understanding how it works. What is p.1 and p.5, what really is lref and rref, what really is LogicalANDExpression and BitwiseORExpression in that context?
BitwiseORExpression here just refers to the (expression for the) right operand, exactly like LogicalANDExpression refers to the left one as you correctly deduced. What it is depends on the code (or rather its parsed form, the AST) that you are currently evaluating, it could be basically anything and does not need to contain an | operator.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With