Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

103
Vistas
Multiple args in javascript function

How can I pass more than one arg in a function without knowing the number of args that I will need to pass?

function uniteUnique(arr) {
(do somthing here)
}

uniteUnique([1, 3, 2], [5, 2, 1, 4], [2, 1]);

what I mean is the func above receive one arg, but the function is called with 3 arg this time, but in other exercise is called with 4 arg.

The best solution in my case was using arguments

function uniteUnique( ){
console.log(arguments)
}
uniteUnique([1, 3, 2], [5, 2, 1, 4], [2, 1]);
// logs { '0': [ 1, 3, 2 ], '1': [ 5, 2, 1, 4 ], '2': [ 2, 1 ] }
// i can work with this
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

This is the way to go if you use typescript/ ES6

function uniteUnique(...arrays) {
(do somthing here)
}

uniteUnique([1, 3, 2], [5, 2, 1, 4], [2, 1]);

where arrays mean variable number of arrays ( could be 2 or 3 or whatever )

or for old javascript / ES5 :

function uniteUnique() {
    (do somthing here , with usage of **`arguments`** object)
    }
    
    uniteUnique([1, 3, 2], [5, 2, 1, 4], [2, 1]);
about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda