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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T22:23:48+00:00 2026-05-13T22:23:48+00:00

I am not clear on the actual difference between these two styles of class

  • 0

I am not clear on the actual difference between these two styles of “class” definitions in JavaScript.

Method a:

function myclass() {}

Method b:

myclass = function() {}

Is there any difference?

  • 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-13T22:23:48+00:00Added an answer on May 13, 2026 at 10:23 pm

    Those are functions, the first one is a function declaration, the second is a variable assignment with a function expression.

    The main difference is that the function declarations are hoisted up in the current scope at parse time, they behave like if you declared them at the top of its enclosing scope.

    The grammar of both is very similar, the only grammatical difference is that the name function expressions is optional, the parser knows which one you are using based on the “context” where you use it, e.g. your first example is a function declaration because the function itself is defined on a Program (technically a place outside of any function, in the global scope), or in FunctionBody (inside a function).

    A function expression is created when it is evaluated itself in expression context, e.g.:

    function foo () {} // function declaration
    (function foo() {}); // function expression
    

    In the above example the second one is interpreted as a function expression because is surrounded by parentheses, and parentheses can only hold expressions…

    I highly recommend you the following in-depth article about the topic:

    • Named function expressions demystified
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I looked for this on the web, but I could not find any clear
I'm not finding my answer in the online git lit. It is clear that
I want to, using PHP, differentiate between an actual person and a bot. I
Ok... so here's my actual status: Been a PHP Scripter for way too long,
I'm not hugely familiar with a lot of WPF yet, so if this query
I have checked all posts here, but can't find a solution for me so
Executive summary: How can I define an arbitrarily-sized 2D array in C? How can
I recently came across code written by a fellow programmer in which he had
Old hand at ASP.NET, new to the UpdatePanel. I have a reporting page which
After reading an interesting article about unit testing behavior instead of state, I came

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.