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

161
Views
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 answers
Answer question

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 Report

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