Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

182
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!