As a first-class object, functions may have properties and methods. They can be nested. The outer function invokes the inner one. In this way, it forms a lexical closure. As a result, the inner function’s internal state becomes the outer function’s lexical scope. As a second-class object, it also supports anonymous functions. Its lexical scope is not affected by the nested function.