Skip to main content
Back to problems
#2703
Easy JavaScript

Return length of arguments passed

94.5% acceptance
Mar 2, 2026
419
176
Write a function argumentsLength that returns the count of arguments passed to it.

Solution

TypeScript
Time O(1)
Space O(1)
LeetCode
solution.ts
type JSONValue =
  | null
  | boolean
  | number
  | string
  | JSONValue[]
  | { [key: string]: JSONValue };

function argumentsLength(...args: JSONValue[]): number {
  return args.length;
}

/**
 * argumentsLength(1, 2, 3); // 3
 */