October DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsSlow PC?RecommendedPC slow today? Run a repair scan before it gets worseResolve common Windows issues and optimize system performance.Scan NowOctober DealsAmazon USDeal season is back - check today's better picksAmazon US: current deals, useful picks and tech finds.See Picks×
Skip to content
World desk4 min

Find a Function’s Parameters, Argument Types, and Call Count

Find a function’s declared parameters, determine how many arguments a call supplies, and understand what Python, JavaScript, and TypeScript can reveal about types.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

The exact method depends on the language—and on whether you mean a function’s declared parameters or the arguments supplied in one call. A signature describes the parameters a function accepts; a call supplies values for them. Defaults and variadic parameters mean those counts do not always match. In Python, start with inspect.signature(fn); in JavaScript, fn.length gives only a limited count of formal parameters; in TypeScript, inspect the function type and any overload declarations.

First distinguish parameters from arguments

Parameters are the named slots in a function’s signature. Arguments are the values provided when calling it. For example, in add(a, b), a and b are parameters; in add(2, 3), 2 and 3 are arguments.

As an Amazon Associate I earn from qualifying purchases.

To find what a function accepts, inspect its signature or type declaration. To count what was supplied in a particular call, examine that call or use a language-specific mechanism available inside the function. Optional or defaulted parameters can be omitted, while variadic parameters can accept additional values, so a signature’s parameter count does not necessarily give a single fixed number of accepted arguments.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

What a function signature can tell you

A signature may describe more than a count: parameter names, whether parameters are positional or keyword-only, optional type annotations, default values, and the return type. The Python typing specification defines a function signature as its parameters—including their names, kinds, optional declared types, and default status—plus its return type. Read the callable typing specification.

Keep the limits of that information in mind. A parameter with no annotation has no declared type to inspect; its missing annotation does not establish what type callers should pass. And some languages keep type information in static declarations rather than exposing it through runtime function objects.

Python: inspect a callable’s signature

Python’s standard-library inspect.signature() returns a Signature object for supported callables. It exposes parameters and their kinds, annotations, and defaults:

from inspect import signature

sig = signature(fn)
print(sig)
for name, param in sig.parameters.items():
    print(name, param.kind, param.annotation, param.default)

Parameter kinds include positional-only, positional-or-keyword, keyword-only, variadic positional (*args), and variadic keyword (**kwargs). The first three describe named parameter slots; *args can collect additional positional arguments and **kwargs additional keyword arguments. Either variadic parameter can receive zero or more values. The signature API and its parameter metadata are documented in the Python 3.12 inspect documentation.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Check param.annotation rather than assuming every parameter has a type annotation. If it is empty, the signature does not declare a type for that parameter.

When Python cannot provide a signature

Not every callable exposes introspectable metadata. In CPython, some C-defined built-ins do not provide argument metadata; inspect.signature() may raise ValueError when it cannot provide a signature or TypeError for an unsupported object. In that case, consult the callable’s official documentation or source instead of inferring its parameters or types.

JavaScript: treat Function.length as a limited count

JavaScript’s fn.length reports a restricted count of formal parameters, not the number of arguments passed in a particular call and not a list of parameter types. For this function, the count is one:

function example(a, b = 1, ...rest) {}
console.log(example.length); // 1

The count includes only parameters before the first default-valued parameter. A destructuring pattern counts as one parameter, and a rest parameter is excluded. The rules are described in MDN’s Function: length reference.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Inside a function, arguments.length reports how many arguments were passed to that invocation. That is a different question from fn.length, which concerns formal parameters. Ordinary JavaScript function syntax does not declare parameter types, so neither count tells you what types callers are expected to provide. For that, consult the function’s documentation or source, or TypeScript declarations if the library supplies them.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

TypeScript: read the callable type and overloads

A TypeScript function type can state parameter and return types, as in (a: string) => void. Required parameters are checked at call sites; a parameter marked with ? is optional. These declarations describe TypeScript’s static contract, not runtime type enforcement by JavaScript. See the TypeScript Handbook: Functions.

A callable type may also have overload signatures that allow different call forms. For example, a function can expose one overload for a timestamp and another for separate month, day, and year arguments. Callers see the overload signatures, which need not match the implementation signature; the implementation signature itself is not visible to callers. To determine valid calls, inspect the exported function type and its overloads rather than relying on the implementation body. The Handbook explains these signatures in More on Functions.

Choose the right method for your question

  • Need the declared parameters? Inspect the language’s signature or type declaration.
  • Need the arguments in one call? Count the values at that call site, or use a mechanism that reports the current invocation’s arguments.
  • Are defaults or optional parameters present? A caller may omit them, so the number supplied can be lower than the number of declared parameter slots.
  • Are parameters variadic? *args, **kwargs, or JavaScript rest parameters can make the number of accepted values variable.
  • Do you need types? Look for annotations or static declarations. Runtime counts alone do not reveal types, and missing annotations are not evidence of a particular type.
  • Is the function overloaded, wrapped, or native? The public call forms or available metadata may differ from the implementation or may not be introspectable.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
Crashes, No Sound, or Screen Glitches?Free driver scan
Windows Errors? Fix Them Before They SpreadFree repair scan

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.