Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8635659
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T10:01:56+00:00 2026-06-12T10:01:56+00:00

Coming from C++ and Java, I am a beginner with Javascript. This code pattern

  • 0

Coming from C++ and Java, I am a beginner with Javascript. This code pattern confuses me (found in a jQuery Application):

var opts = { drop : empty};

function drop(arg){
    opts.drop(arg);
    //do something
}

How I would read this:
The object opts is created and the attribute drop is declared, but initialized as empty.
Then, the function(-object) drop is defined. In the second line, the drop-attribute of the opts object is called as a method. But, in my understanding, opts.drop is empty. So it should not be callable.

What happens here? Am I missing some important code, or is this a pattern that makes sense?

EDIT: Source: https://github.com/weixiyen/jquery-filedrop/blob/master/jquery.filedrop.js

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T10:01:58+00:00Added an answer on June 12, 2026 at 10:01 am

    empty is likely the name of a function, which is implemented like:

    function empty () {}
    

    If it were null, undefined, a string, an object, an array, etc… …then there’d be reason to be concerned, because that would end poorly.

    But my gut tells me that if you look for its definition, empty === function () {}

    For added confusion, if empty is defined as an assignment:

    var empty = function () {};
    

    That assignment must happen above where it’s being referenced in opts.

    If, however, it’s a declaration:

    function empty () {}
    

    that function could be declared anywhere, including the bottom of the script, because function-declarations are compiled before anything else in the script.

    EDIT

    Doing a quick check, I’m seeing a few different empty functions at different scopes.
    Some are removing callbacks from an array (by setting the array to an empty one), some are removing HTML elements from a parent, and some are checking if an element has any child elements.

    Of course, I’m viewing the minified source from this site, so there may be more empty functions out there.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am coming from Java to Ruby and this -7 mod 3 = 2
Background: I'm coming from Java background so not too familiar with Javascript. We are
I am coming from Java and try to learn Javascript right now. Doing that
Coming from a Java background, this is the way I'm thinking: The server provides
Coming from Java background I am guessing this is expected. I would really love
Coming from Java, I'm wondering if a Java best practice applies to JavaScript. In
I'm coming from java so this is entirely new to me. I have Visual
Possible Duplicate: How does JavaScript .prototype work? Coming from Java background, I'm trying to
Coming from Java , I'm used to the package structure (com.domain.appname.tier) Now I've started
new to Laravel (coming from Java spring), while using Route::get('/', function() { return Hello

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.