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

186
Vistas
How to get all params exept '.$0' and '._' using yargs

When I am using yargs module to simplify params handling

Yargs always reruns params as an object, here is an example, if I run this command node index.js default --optipn1=true --option2=false --custom

Yargs return this array:

{
  _: [ 'default' ],
  optipn1: 'true',
  option2: 'false',
  custom: true,
  '$0': 'index.js'
}

What I want is the same array of params excluding _ and $0,

{
  optipn1: 'true',
  option2: 'false',
  custom: true,
}

is there anyway to do that that?

Is there any built-in functionality to achieve that?

about 4 years ago · Juan Pablo Isaza
2 Respuestas
Responde la pregunta

0

const obj = {
  _: [ 'default' ],
  optipn1: 'true',
  option2: 'false',
  custom: true,
  '$0': 'index.js'
};


let newObj = {};


for(let [key, value] of Object.entries(obj)) {
  if(key != '_' && key != '$0') {
    newObj = {...newObj, [`${key}`]: value}
  }
}

console.log(newObj)

Here we go ;) I hope be useful for you

about 4 years ago · Juan Pablo Isaza Denunciar

0

let obj = {
  _: ['default'],
  optipn1: 'true',
  option2: 'false',
  custom: true,
  '$0': 'index.js'
};
let {_, $0, ...targetObj} = obj;
console.log(targetObj);
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