Last active
October 27, 2015 03:37
-
-
Save rnaffer/95314e83a650427a406d to your computer and use it in GitHub Desktop.
Ejemplo del patrón de diseño "Function Argument" con explicación.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// "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