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

138
Views
How can we pass object as a parameter to a function name in Object value?

I want to pass an object to a function which is a value of another object. Is this possible, how can we do that? I can pass a string easily and a variable as a string. But, cannot pass as an object.

I have 2 objects like:

var test1 = "qwerty";
var test2 = { qwerty: "sdaf" };

I want to pass these objects as a parameter to an object value like the below.

var props = {
   event: `backdropEvent("${test}")`,
}
function backdropEvent(e){
 console.log(e)
}

When I tried to pass test1 I get it as a string. How can I pass the test2 object?

var test1 = "qwerty";
var test2 = { qwerty: "sdaf" };

var props = {
   event: `backdropEvent("${test2}")`,
}

function backdropEvent(e){
 console.log(e)
}

function testFn(){
testFn2(props);
}

function testFn2(e){
var x = Function(e.event);
x();
}
<button onclick="testFn()"> click me </button>

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

I may be mistaken since its a little hard to understand what you are trying to accomplish but I beleive that you want to use function binding

const test2 = { qwerty: "sdaf" };

const backdropEvent = (e) => {
    console.log(e);
}

const props = {
    event: backdropEvent.bind(null, test2)
}

props.event()

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