Skip to content

Instantly share code, notes, and snippets.

@rnaffer
Last active October 27, 2015 03:37
Show Gist options
  • Save rnaffer/95314e83a650427a406d to your computer and use it in GitHub Desktop.
Save rnaffer/95314e83a650427a406d to your computer and use it in GitHub Desktop.
Ejemplo del patrón de diseño "Function Argument" con explicación.
// "arguments" contiene todos los argumentos pasados a la función.
// Util en caso de que el numero de argumentos posibles sea indeterminado.
// En el ejemplo se suman los números pasados como argumentos, aunque no verifica antes si son números.
function mySum() {
var x = 0,
i = 0,
length = arguments.length;
for ( ; i < length; i++ ) {
x = x + arguments[i];
}
return x;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment