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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T12:56:51+00:00 2026-06-18T12:56:51+00:00

I started JavaScript programming last month, i know basic syntax like objects, functions, class,

  • 0

I started JavaScript programming last month, i know basic syntax like objects, functions, class, string, array, property. Now i was puzzled on given syntax.

Syntax:

(function(){

 "use strict";

})();

My question is, why two parenthesis( one contains ‘function’ and another “empty” ) are included in the definition? can some one help me why we use 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-18T12:56:53+00:00Added an answer on June 18, 2026 at 12:56 pm

    What you have there is a self-invoking function.

    It pretty much is exactly that, a function which immediately gets called. To accomplish that, we need a function expression, not a function declaration. To achieve that, we can do certain things, one of those is, to put the whole expression in parenthesis

    (function() {});
    

    this statement creates a function expression. Now all we have left to do is, to invoke that function by appending additional function parenthesis, like we would do with any function

    (function() {})();
    

    You can also put the function parenthesis into the whole statement, it makes no difference

    (function() {}());
    

    Another option to bring a function into an expression form is by using ! or + signs infront of it

    !function(){}()
    

    Anything goes, as long we create an expression, we can’t invoke a function declaration like that

    function foo(){}() // syntax error
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I started learning programming 4 months ago. So far I already know some javascript(and
I just started learning my first real programming language, Python. I'd like to know
I started learning JavaScript a while ago. It's a fairly easy programming language considering
I'm a matlab programmer and started to work with javascript. I wanted to know
I'm new to jQuery and to some extent JavaScript programming. I've successfully started to
I recently started programming JavaScript and thought everything would be good... Well today I
I just started with OOP on Javascript. I am new to programming world. Could
I started learning JavaScript last week, I saw this code yesterday and I did
I've just started JavaScript and I am facing a problem. I've written a script
When I first started with Javascript, I usually just put whatever I needed into

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.