Dada esta función (por ejemplo, en node.js)
> function f (a = 1) { return arguments; } undefined > f(1) [Arguments] { '0': 1 } // arguments object contains value for argument a > f() // invoke function f without argument [Arguments] {} // arguments object is empty despite default valueNecesito poder obtener valores predeterminados si no se da ningún argumento.
¿Puede alguien ayudarme con esto?
Directamente de los documentos: arguments is an Array-like object accessible inside functions that contains the values of the arguments passed to that function.
Esto significa que los arguments solo contendrán los valores que realmente se pasan a la función cuando se realiza una llamada.