Main | Yield! »
Friday
May062011

Named arguments

In Mascara 1.8.1 a limitation have been fixed. Previously, named argument could only be used with optional parameters. Now named arguments can be used with both required and optional parameters.

Named arguments can help making function calls more understandable in cases where the meaning of arguments is not immediately obvious. For example this:

document.importNode(elem, true)

Is probably not as clear as this:

document.importNode(elem, deep=true)

When using named arguments, the order of the arguments doesn't matter, as long as a value is provided for all required parameters. Both named an unnamed arguments can be used in the same call (as shown above), but named arguments must follow after all unnamed arguments.

PrintView Printer Friendly Version

EmailEmail Article to Friend