re: Why (! + [] + [] + ![]).length is 9 VIEW POST


If I'm not sure what's going on with the JS code, I use ASTexplorer to look at the code with the compiler's eyes. It converts a code string into the tree of instructions to be executed by the compiler step by step.
But sometimes text representation of a tree is not expressive enough, so I built a little tool which visualizes an AST tree.
For (! + [] + [] + ![]).length AST in graph form looks like this:
In runtime calculations starts from the bottom left and flow to the top.

code of conduct - report abuse