views:

8

answers:

1

When calling something like this

var e = Function._validateParams(arguments, [
                { name: "target", type: Array, elementMayBeNull: true },
                { name: "index", type: Number, integer: true },
                { name: "deserializing", type: Boolean, optional: true }
            ]);

what does the optional property mean? I was expecting it to mean that I could omit that parameter entirely, but I'm getting an exception that the parameter cannot be undefined. It seems to be looking for mayBeNull instead. So what does optional do?

A: 

So it appears that optional does do what I expected. The problem was that we had function A which had an optional parameter, and it then called function B passing that parameter. Even though the parameter was also optional in B, optional only works if you omit the parameter, and now we were actually passing a parameter (whose value was undefined), thus causing the exception in function B.

bwarner