TomFrost / Jexl

Javascript Expression Language: Powerful context-based expression parser and evaluator
MIT License
559 stars 90 forks source link

'&&' and '||' priority #110

Open VincentWuShiChao opened 3 years ago

VincentWuShiChao commented 3 years ago

The priority of the current module is && and | | is the same,The result of ' 'true && true || false && false'' is false.But in JavaScript, '&&' than '| |' priority,so The result of ' 'true && true || false && false'' is true.

My solution so far is to rewrite the priorities。The following: jexl.addBinaryOp('&&', 11, (left, right) => { return left && right; });

TomFrost commented 2 years ago

Sorry for the late response to this -- this is a great observation. While Jexl's goal isn't to mirror Javascript, I think this is a great move for predictability. It is a breaking change, though, so this will come in the next major version release.