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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T22:52:48+00:00 2026-06-02T22:52:48+00:00

I think I understand the module pattern, but why do some examples pass JQuery

  • 0

I think I understand the module pattern, but why do some examples pass JQuery in as a parameter like this:

Namespace.AppName = (function ($) {
     // Code Here
})(jQuery); 

If I don’t pass in JQuery I can still use the Jquery library just fine by making $() calls inside the module. So why do some people do this?

  • 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-02T22:52:49+00:00Added an answer on June 2, 2026 at 10:52 pm

    The idea here is that you pass jQuery as $ to the inside function, making sure that the $ IS jQuery. This is commonly used to protect code that uses $ especially when using jQuery along with other libraries that use $ like mootools.


    example, if you had this code in the <head>

    <!--load jQuery-->
    <script src="jquery.js"></script>
    
    <script>
        //"$" is jQuery
        //"jQuery" is jQuery 
    </script>
    
    <!--load another library-->
    <script src="anotherlibrary.js"></script>
    
    <script>
        //"$" is the other library
        //"jQuery" is jQuery 
    
        //out here, jQuery code that uses "$" breaks
    
        (function($){
            //"$" is jQuery
            //"jQuery" is jQuery (from the outside scope)
    
            //in here, jquery code that uses "$" is safe
    
        }(jQuery));
    
    </script>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I think I understand strong typing , but every time I look for examples
I was reading this article about the module Javascript pattern , but I don't
I think understand the idea of duck typing, and would like to use it
I think I understand unit testing. But I was wondering: is there a way
I think I understand the basic principals of T4 but I'm having a hard
So I (think I) understand the difference between Float, Double, and Decimal , but
I am using the Javascript Module Pattern to try and implement C# enumeration-like functionality.
I'm trying to learn how to use the Control.Parallel module, but I think I
I've been actively using the revealing module pattern for years but there's a few
I am trying to link a C++ module using GCC, essentially like this: gcc

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.