I have a typical javascript function with some parameters
my_function = function(content, options) { action }
if I call the function as such :
my_function (options)
the argument “options” is passed as “content”
how do i go around this so I can either have both arguments passed or just one ?
thank you
You have to decide as which parameter you want to treat a single argument. You cannot treat it as both,
contentandoptions.I see two possibilities:
function(options, content)Check whether
optionsis defined:But then you have to document properly, what happens if you only pass one argument to the function, as this is not immediately clear by looking at the signature.