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

98
Vistas
Access [[scope]] of the function from api response
drop: (item, monitor) => addTaskToSprint(item.id, monitor, drop)
    length: 2
    name: "drop"
    arguments: (...)
    caller: (...)
    [[FunctionLocation]]: SprintCard.jsx:45
    [[Prototype]]: ƒ ()
    [[Scopes]]: Scopes[3]
        0: Closure (SprintCard)
           ItemType: "Task Card"
           addTaskToSprint: (id, monitor, dropTargetProps, task) => {…}
           drop: ƒ ()

My api response looks like this,

I need to access [[Scopes]] so I can get the ItemType variable

drop is a function so accessing the scope like so (spec.drop.scopes) won't work

when I console.log(spec.drop) it shows the function declaration only

So is there any way to have access scopes?

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

0

[[Scopes]] isn't a part of the object, it's a category devtools uses to show what environment record objects a function closes over. The drop function has access to ItemType, but other code doesn't get access to ItemType via drop unless drop provides that access in some way. More generally, code with access to a function doesn't necessarily have access to the things that function has access to (in fact, it often doesn't).

Here's a simpler example:

function counter() {
    let value = 0;
    const increment = () => ++value;
    return increment;
}

function example() {
    const increment = counter();
    console.log(increment()); // Shows "1"
    console.log(increment()); // Shows "2" -- that is, the `increment`
                              // function closes over `value` so it
                              // can use it to return an incrementing
                              // counter

    // There's no way for code here to directly access the `value` that
    // `increment` closes over.
}

example();

The increment function has access to value, but the example function does not, even though it has access to increment.

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