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

162
Vistas
How does a parameter become a function call in JavaScript?

I often like to say that JS is not my home language and that's led me to this question.

import Dropzone from "dropzone";

let myDropzone = Dropzone({
  paramName: "file", // The name that will be used to transfer the file
  maxFilesize: 2, // MB
  accept: function(file, done) {
    if (file.name == "justinbieber.jpg") {
      done("Naha, you don't.");
    }
    else { done(); }
  }
});

The preceding code is from Dropzone website about their great file upload tool.

The else done() confuses me. How would you know that's a function if you were calling this? Done sports appears to be a parameter to me. If I'm using a good IDE, would I be directed as such? If not how do I know?

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

0

In Javascript, every function is an object, and can be used just like an object.

You can call

console.log(typeof done)

to see that the parameter is a function.

about 4 years ago · Juan Pablo Isaza Denunciar

0

JS uses duck typing, which in this case means that the value of done is checked just before trying to call it. If it's callable, everything is good. If not, an error is thrown at runtime.

As to whether your IDE will tell you about this, that will depend on how good your IDE is at doing static typechecks, but I'd assume it's not a common feature. Duck typing is very permissive, making it generally difficult to determine whether some code will throw an error without running it.

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