During lexical analysis, the lexer scans the source code to convert it into a stream of tokens. While doing this, it typically discards whitespace (spaces, tabs, and newlines) and comments, as these elements are not necessary for the syntactic or semantic understanding of the code.