What happens if I don't pass a parameter in a Javascript function?

Nothing will happen- meaning you won't get an error or a warning as passing the parameters in javascript is optional.
All the parameters that weren't "supplied" will have the undefined value.

function foo(x, y, z){
    //...
}

foo(1);

Inside the foo function now:

function foo(x, y, z){
    x === 1
    y === undefined
    z === undefined
}

You can even pass more arguments, like:

foo(1,2,3,4,5,7); // Valid!

You can know the amounts of parameters supplied by arguments.length from inside the function.

function foo(x, y, z) {
    console.log('x value: ' + x);
    console.log('y value: ' + y);
    console.log('z value: ' + z);
    console.log('Arguments length: ' + arguments.length);
}
console.log('Zero parameters');
foo();
console.log('Four parameters');
foo(1, 2, 3, 4);

Example of useful function that handle any amount of parameters:

function max() {
    var maxValue = arguments[0];
    for (var i = 1; i < arguments.length; i++) {
        if (maxValue < arguments[i]) {
            maxValue = arguments[i];
        }
    }
    return maxValue;
}

alert(max(1, 5, 7, 2, 88, 32, 44));


All arguments in JavaScript functions are optional (read "loosely typed").

JavaScript functions can be invoked with any number of arguments, regardless of the number of arguments named in the function definition. Because a function is loosely typed, there is no way for it to declare the type of arguments it expects, and it is legal to pass values of any type to any function. When a function is invoked with fewer arguments than are declared, the additional arguments have the undefined value.

You can refer to a function's arguments within the function by using the named argument variables or the arguments object. This object contains an entry for each argument passed to the function, the first entry's index starting at 0. For example, if a function is passed three arguments, you can refer to the argument as follows:

arguments[0]
arguments[1]
arguments[2]
  • JavaScript - The Definitive Guide, 5th Edition

That's just how JavaScript works. Parameters are optional, and will have the not-really-a-value value "undefined" in the function if they're missing from a function call.

By "optional" I mean just that: invoking any function involves an arbitrarily long list of parameters. There need be no relationship between the number of parameters passed to a function and the number declared. Best way to think of this declaration, then:

function x(a, b, c) {
  // ...
}

is that you're declaring a function and binding the name "a" to the first parameter, "b" to the second, and "c" to the third. It's by no means guaranteed, however, that any of those will actually be bound to a value in any given invocation of the function later.

By the same token, you can define a function without any parameters at all, and then "find" them via the arguments object:

function noArgs() {
  var a = arguments[0], b = arguments[1], c = arguments[2];
  // ...
}

So that's not quite the same as the first function, but it's close in most ways that count practically.

The "undefined" value in JavaScript is a value, but it's semantics are kind-of unusual as languages go. In particular it's not exactly the same as the null value. Also, "undefined" itself is not a keyword; it's just a semi-special variable name!