A function is a first-class object that can have properties and methods. A nested function is defined within a function. When the outer function is invoked, a nested one is created. It forms a lexical closure, and the outer’s lexical scope becomes part of the inner-function object. There are also different ways to define a nested function. You can define a prototype of a nested function.