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

  • SEARCH
  • Home
  • 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 7820865
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T07:27:28+00:00 2026-06-02T07:27:28+00:00

A simple question. I have a web project includes multi JavaScripts. JS: // (1)

  • 0

A simple question.

I have a web project includes multi JavaScripts.

JS:

// (1) Event

$('.input').keyup(function()
{
    keyUpFunction();    
});


// (2) Function

function keyUpFunction(){ ... }

(1),(2) which should come first in one javascript file? If the browser read the function first, does it store the function in memory and invoke it when scan the event.

In some case, the same function is defined in multi javascript . e.g.

prm.add_endRequest(function() {
    fn1();
    fn2();
});

$(document).ready(.......)

Should I duplicate the function name and define each component in each js file.
or keep the function declare in one file and invoke sub-function composite the function?

  • 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-02T07:27:30+00:00Added an answer on June 2, 2026 at 7:27 am

    Functions defined in the following manner:

    function fooBar(){}
    

    Are ‘hoisted’ to the top of the current scope. This means they will always be available, in the current scope, even if they are defined at the end of the file.

    This does not hold true if you defined you functions like this:

     var fooBar = function(){};
    

    These functions are not hoisted, and must be defined before they can be used.

    It should be noted that in your specific example, keyUpFunction will only be called once a keyup event has fired. This also means that all javascript on your page will already be evaluated, so the keyUpFunction will be defined (parsed) already regardless.

    EDIT: To be more explicit, this first example is okay:

    doSomething('hello world');
    function doSomething(str){ 
       console.log(str);
    } 
    

    However, this will cause you problems:

    doSomething('hello world');
    var doSomething = function(str){ 
       console.log(str);
    } 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

A simple question. I have an ASP.NET web application which contains several assemblies and
just simple question, recently i have setup a web server to build project using
very simple question: I have admin site in my web project. So, how can
I have a simple question: if I use URLConnection.setUseCaches(true) when loading something from web,
I have a web service project and simple test application. I can debug the
I have a simple question about adding references to a .NET project. I'm adding
I'm preparing project for web application with large AJAX usage, which should work on
Here's a simple design patterns question: As part of my current project, I have
I have a large-ish web project which is migrating from classic ASP to ASP.NET
simple question: I have an file online (txt). How to read it and check

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.