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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T17:51:58+00:00 2026-05-28T17:51:58+00:00

Possible Duplicate: !function(){ }() vs (function(){ })() So I was just reading through the

  • 0

Possible Duplicate:
!function(){ }() vs (function(){ })()

So I was just reading through the source of the new Bootstrap (2.0) from Twitter and noticed that there is an exclamation mark before the self-invoking anonymous function. When I saw this I immediately thought “Oh crap, there’s a new, better way to do this?”.

See for yourself!

  • http://markdotto.com/bs2/js/bootstrap-modal.js
  • http://markdotto.com/bs2/js/bootstrap-dropdown.js
  • http://markdotto.com/bs2/js/bootstrap-scrollspy.js
  • http://markdotto.com/bs2/js/bootstrap-popover.js
  • http://markdotto.com/bs2/js/bootstrap-tooltip.js
  • http://markdotto.com/bs2/js/bootstrap-tab.js

Anyways, what’s the difference? There must be a reason for it because they use it consistently in all of their JavaScript plugins (for Bootstrap).

Another thing I noticed was the “use strict” right after this. I don’t think it’s related to my previous inquiry, but can anyone explain this?

Thanks!

  • 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-05-28T17:51:59+00:00Added an answer on May 28, 2026 at 5:51 pm
    function(){} ();
    

    By itself (see Point’s comment) isn’t going to be valid, since

    function() {}
    

    is a function declaration. To invoke it immediately, you need to get the JavaScript engine to treat the function as an expression. People usually do this as either of

    (function(){}) ();  //more common
    
    (function(){} ()); // Papa Crockford's preference:
    

    with

    !function(){}();
    

    simply being a shorthand version of the same thing.

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

Sidebar

Related Questions

Possible Duplicate: How does foreach work when looping through function results? If I have
Possible Duplicate: C++ passing variables in from one Function to the Next. The Program
Possible Duplicate: Access return value from Thread.Start()'s delegate function public string sayHello(string name) {
Possible Duplicate: Explain JavaScript's encapsulated anonymous function syntax I have just read a javascript
Possible Duplicate: Finding the Variable Name passed to a Function in C# public new
Possible Duplicate: Get just the Date from grouping in select from DateTime column in
Possible Duplicate: How can I call a new web page from javascript / jQuery
Possible Duplicate: What's the nearest substitute for a function pointer in Java? I just
Possible Duplicate: What is the point of function pointers? I just read about pointers
Possible Duplicate: Ruby functions vs methods Im just reading some ruby documentation and t

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.