Optional function arguments/parameters by using associative array


/ Published in: JavaScript
Save to your folder(s)

By not being limited to provide certain arguments/parameters in right order when calling a function, makes the function more versatile and easier to extend without breaking old code (e.g. calls to the function).
One solution is to pass an associative array holding the parameters.
Advantage: argument order is unnecessary, each argument have a label - easier to remember.

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.