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

183
Vistas
More elegant and secure solution to passing object path references

I've been reading SICP and one concept they teach is abstracting certain details away from the user. I'm trying to build a set of subfunctions that return object paths that can be passed as an argument in a higher order function. The problem I found was that most of the time javascript will resolve the object path to whatever value it's referencing before passing it to the higher order function. With some help I managed to cobble together this crude solution but I was hoping theres a better way.

let object = {
prop1: "sth",
prop2: "sthelse"
}
function getPath(whichProp) {
    return `object["${whichProp}"]`};

function deleteProp(aPath) {
    console.log(aPath) //prints object["prop1"]
    eval(`delete ${aPath}`);
    console.log(object) // {prop2: sthelse}
}

deleteProp(getPath("prop1"))

Is there some method of message passing that can be used here? Having the function resolve to a function calling it's argument with itself as that functions' argument. Hope that's coherent, thanks in advance.

about 4 years ago · Juan Pablo Isaza
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