A quick terminology note: parameters are the variables in the function definition. Arguments are the actual values you pass when calling the function.
Copy
// "name" and "age" are parametersfunction createUser(name, age) { return { name, age };}// "Sarah" and 28 are argumentsconst user = createUser("Sarah", 28);console.log(user); // { name: "Sarah", age: 28 }
In practice, people use the terms interchangeably. Don’t worry about it.
Python mental model: JavaScript is more permissive than Python here. If you pass too few arguments, the missing ones become undefined (instead of raising a TypeError). If you pass extra arguments, JavaScript ignores them unless you collect them with a rest parameter (...args).
Same concept, same position — defaults go in the parameter list. JavaScript uses =, Python uses =. No surprises here.
One important JavaScript difference: default parameters are used when the argument is missing or explicitly undefined. Passing null does not use the default.
function sum(...numbers) { return numbers.reduce((total, n) => total + n, 0);}
Copy
def sum(*numbers): return sum(numbers) # Built-in sum works on tuples
JavaScript uses ...args, Python uses *args. Same idea.
In JavaScript, ... is used in multiple places (rest parameters, spread syntax). In Python, *args and **kwargs are split into separate syntaxes/uses. Same family of idea, different syntax rules.
The rest parameter must be the last parameter. function bad(...args, last) is a syntax error.
Destructured parameters with defaults are the cleanest way to handle options objects. You’ll see this pattern in API client functions, React components, and configuration.
Python mental model: this is often nicer than passing a long list of positional args, and it plays a similar role to keyword-argument style APIs (func(url=..., timeout=...)) — but in JavaScript you’re usually passing a single options object.
You know how to define functions and pass data into them. Next, let’s understand where variables live — scope determines which parts of your code can see which variables.