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

134
Vistas
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 Respuestas
Responde la pregunta

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 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