Problem: A Javascript function needs few parameters to work with:
function kick(person, reason, amount) {
// kick the *person* with the
JavaScript functions are signed by their name only.
Hence you can do:
function kick(x, reason, amount) {
if(reason && amount) {
// do stuff with x as person, reason and amount
}
else if(x) {
// do stuff with x as config
}
else {
// do stuff with no parameters
}
}
another solutions is to use the arguments variable which is an array that holds all parameters that passed to a function in javascript
function kick() {
alert(arguments.length);
}