How many arguments were passed?

Java (JDK 10), 11 bytes

a->a.length

Try it online!


JavaScript, 15 bytes

[].push.bind(0)

The Array.prototype.push function takes any number of arguments, adds them to its array, and returns the size of the array. Therefore, the push function used on an empty array returns the number of arguments supplied to push.

f = [].push.bind(0)

f(10,2,65,7)
> 4

f()
> 0

The .bind(0) simply gives the push function a fixed this value so that it can be stored in a variable. In fact, the 7-byte identifier [].push can be used literally (but not assigned) without bind:

[].push(10,2,65,7)
> 4

[].push()
> 0

JavaScript (ES6), 16 bytes

(...a)=>a.length

f=
(...a)=>a.length

console.log(f())
console.log(f(1))
console.log(f(1,2))
console.log(f(1,2,3))
console.log(f(1,2,3,4))