When calling _validateParams, what does the optional property do?
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 enti开发者_运维技巧rely, 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?
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.
精彩评论