A function is a first-class object, with properties and methods. A nested function is a function defined within another. It is created when the outer function is invoked. It is a lexical closure, and its lexical scope becomes part of the inner function object’s state. It is possible to call a function through an expression. If a database query is required, a user should pass the corresponding parameter in the code.