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 9041203
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T10:10:59+00:00 2026-06-16T10:10:59+00:00

I got this code block: (function($, exports) { var mod = function(includes) { if

  • 0

I got this code block:

(function($, exports) {
    var mod = function(includes) {
        if (includes) this.include(includes);
    };
    mod.fn = mod.prototype;
    mod.fn.proxy = function(func) {
        return $.proxy(func, this);
    };
    mod.fn.load = function(func) {
        $(this.proxy(func));
    };
    mod.fn.include = function(ob) {
        $.extend(this, ob);
    };
    exports.Controller = mod;

})(jQuery, window);

(function($, Controller) {
    mod = new Controller;
    mod.toggleClass = function(e) {
        this.view.toggleClass("over", e.data);
    };
    mod.load(function() {
        this.test = 'test';
        console.log(this.test); // Delayed
        this.view = $("#view");
    });

    console.log(mod.view) // returns undefined
    console.log(mod);

})(jQuery, Controller);

when executing on firefox, the result on firebug console panel is as follows:

undefined
Object { toggleClass=function(), proxy=function(), load=function(), more...}
test

That means the last two log functions (they’re placed at the bottom of the code block) was executed before the first one (which is : console.log(this.test); // Delayed)

Could you explain why the flow happened in this way?

  • 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-16T10:11:00+00:00Added an answer on June 16, 2026 at 10:11 am

    Could you explain why the flow happened in this way?

    Because you set up the code in the function you passed into load to wait until DOM ready, by (inside your load function) passing a function reference into the jQuery $ function. When you pass it a function reference, that’s a shortcut for $(document).ready(...). DOM ready doesn’t happen until after your other code runs, so you don’t see the output from the contents of the function you’re passing into load until after your other outputs.

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

Sidebar

Related Questions

I've got this code: $('a').click( function() { $(#change_flash).css(display, block); $(#my_flash).css(display, none); }); But this
Does anyone know what's wrong with this code block. CREATE FUNCTION [dbo].[udfGetPoint] ( @UserID
Got this code for a viewscroller from the apple developers site. @synthesize scrollView1, scrollView2;
I got this code from our frontend guy for headings: <h2 class=headline><span>Foobar</span></h2> The span
I got this code in order to build an url for the link using
I got this code from the wordpress <head profile=http://gmpg.org/xfn/11> What does this means? what
I got this code ` // // prints out Hello World! // hello_world(); //First
i got this code $current_path = str_replace('\', '/', getcwd()); //c://xampp/htdoc Why it fail replace
I got this code in my submit form <form id=myform action='hello.php' method='GET'> <input type=button
I got this code from someone, it's almost perfect to create a dynamic breadcrumb,

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.