Basically, it comes down to the difference between »concrete syntax« and »abstract syntax«.
- Concrete syntax: derived tree which contains elements that are only necessary to recognize the structure
- Abstract syntax: derived tree which contains an abstraction of elements that aren’t essential for semantics
It’s »concrete« because the structure is a grammatical copy of the code/text, token by token, just in a tree format.
An AST only contains information that is related to analyzing the source code/text and ignores any kind of extra syntactic information used for parsing the code/text.
querySelectorAll, for example. This allows compilers/transpilers (e.g. Babel) to »understand« source code and apply specific transformations to it accordingly.
astexplorer.net is a great web-based tool to explore the AST representations generated by various parsers for all sorts of programming languages.