Function declaration
A function declaration is a source-language construct that introduces a function by specifying its name and parameter interface, and may also provide its implementation.
Secrets of the JavaScript Ninja, Second Edition
A JavaScript statement that defines a named function.
- How it is used
- Defines named JavaScript functions as standalone statements, distinguishing them from function expressions when deciding where a function is available for invocation.
- How deep it goes
- Explains required syntax, nesting, and early identifier registration in lexical environments, while deferring detailed scope and identifier resolution.
- Examples
- Compares nested declarations with function expressions and tests access to a function before its declaration executes.
- What you can do after
- Build it from scratch as a named statement and predict when calls before its declaration work in global or function environments.
Read how Secrets of the JavaScript Ninja, Second Edition explains function declaration →
A Pythonic Adventure: From Python basics to a working web app
A function definition is a Python statement that declares a function's name, arguments, and indented body.
- How it is used
- Defines reusable menu behavior so one operation can serve drinks, flavors, and toppings.
- How deep it goes
- Explains def syntax, arguments, indentation, return values, default arguments, and calls through a menu program.
- Examples
- Uses a coffee-shop menu with drink, flavor, and topping lists, including interactive selections and printed orders.
- What you can do after
- Build it from scratch: declare a menu function, call it with different lists, and return each selected item.
Modern C
A function declaration is a C declaration that specifies a function's name, parameter interface, and return type without necessarily defining its body.
- How it is used
- Distinguishes a function’s declared interface from the body that defines it.
- How deep it goes
- Explains the declaration–definition distinction through main, without elaborating declaration compatibility or linkage.
- Examples
- Uses main as a function definition and printf as a function call.
- What you can do after
- Evaluate whether a function declaration also supplies a definition by identifying its body.
Secrets of the JavaScript Ninja, Third Edition
A function definition is source code that declares a function and specifies its parameters and executable body.
- How it is used
- Defines a named function as a standalone JavaScript statement.
- How deep it goes
- Specifies required syntax and statement placement, demonstrates nesting, and defers scope resolution and early-call behavior.
- Examples
- Shows named declarations, including a function declared inside another function.
- What you can do after
- Build it from scratch using a required name, optional parameters, and a braced body in a standalone statement.
Read how Secrets of the JavaScript Ninja, Third Edition explains function declaration →
Get Programming: Learn to code with Python
A function definition is a Python construct that declares a function's name, parameters, and executable code block.
- How it is used
- Defines reusable Python modules that accept values, perform an action, and return a value.
- How deep it goes
- Explains syntax, indentation, docstrings, calls, returns, and function scope, but stops short of deeper implementation details.
- Examples
- Uses attendance checking, string concatenation, quick-check definitions, and a tip-calculation exercise.
- What you can do after
- Build it from scratch by defining functions, documenting them, calling them with values, and using returned results.
Read how Get Programming: Learn to code with Python explains function declaration →
Modern C, Third Edition
A function definition is a C construct that specifies a function's declaration and body.
- How it is used
- Distinguishes function declarations from definitions and identifies main as the starting point of program execution.
- How deep it goes
- Explains the distinction through declarations, return types, parameter lists, function bodies, and enclosing braces.
- Examples
- Uses main(void) and main with argc and argv to show declarations followed by executable function bodies.
- What you can do after
- Evaluate whether a function name has only a declaration or a complete definition containing a body.
Read how Modern C, Third Edition explains function declaration →
Learn AI-Assisted Python Programming, Second Edition
- How it is used
- Uses function declarations to organize reusable input-processing-output tasks and prompt Copilot to generate Python code.
- How deep it goes
- Explains function headers through their keyword, name, inputs, colon, body, and returned output.
- Examples
- Uses a larger function that compares two numbers, alongside the mathematical example f(x) = x².
- What you can do after
- Build it from scratch by writing a Python function header, defining its body, and returning a result.
Read how Learn AI-Assisted Python Programming, Second Edition explains function declaration →
Also covered in
- Functional Programming in Scala, Second Edition
- The Quick Python Book, Fourth Edition
- AI Agents in Action
- Kotlin in Action, 2E
- Tiny Python Projects: Learn coding and testing with puzzles and games
- JavaScript in DepthIn early access (MEAP)
- Fast Python: High performance techniques for large datasets
- Think Distributed Systems
- Terraform in Depth: Infrastructure as Code with Terraform and OpenTofu
What to know first
- functionA function is a callable unit of program code that performs a computation or operation, can accept inputs, and may produce a result or side effect.
- arrayAn array is an ordered collection of elements organized in one or more dimensions and accessible by position or index.
- loopA loop is a programming-language control-flow construct that repeatedly executes a block of instructions according to an iteration rule or continuation condition.
- callA call is an invocation that requests execution of a function, routine, command, or tool, optionally supplying arguments.
Related concepts
- function expressioncontrasts with · A function expression is an expression that creates a function value, which can be assigned, passed, or used within another expression.
- declarationcontrasts with · A declaration is a language construct that introduces a program entity or name and specifies information about it, such as its type or properties.
- inputhas part · An input is information, a value, or an action supplied to a system, program, or computation for processing or to influence its behavior.
- parameterhas part · A parameter is a value or named input that specifies or influences the behavior, computation, or output of a function, model, or system.
- functionpart of · A function is a callable unit of program code that performs a computation or operation, can accept inputs, and may produce a result or side effect.
- return typehas part · A return type is the type, or absence of a type, associated with the result a function or method supplies to its caller.
Questions about function declaration
What is function declaration?
A function declaration is a source-language construct that introduces a function by specifying its name and parameter interface, and may also provide its implementation.
Which Manning books explain function declaration?
Secrets of the JavaScript Ninja, Second Edition, A Pythonic Adventure: From Python basics to a working web app, Modern C, Secrets of the JavaScript Ninja, Third Edition, Get Programming: Learn to code with Python, Modern C, Third Edition and Learn AI-Assisted Python Programming, Second Edition.
What should I know before learning function declaration?
Manning books that teach function declaration usually introduce function, array, loop and call first.
What is the difference between function declaration and function expression?
A function declaration is a source-language construct that introduces a function by specifying its name and parameter interface, and may also provide its implementation. A function expression is an expression that creates a function value, which can be assigned, passed, or used within another expression.
What is function declaration part of?
Function declaration is part of function. A function is a callable unit of program code that performs a computation or operation, can accept inputs, and may produce a result or side effect.
What are the parts of function declaration?
Function declaration includes input, parameter and return type.
These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.






