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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T21:50:05+00:00 2026-06-01T21:50:05+00:00

What is the connection between the outer var Message and the inner var Message?

  • 0

What is the connection between the outer var Message and the inner var Message?

The Call

new Message ( element ).display( server_response_text.slice( 6 ) );

Object

var Message = ( function () 
{
    var messages = 
    {
        name:         'Please enter a valid name',
        email:        'Please enter a valid email',
        email_s:      'Please enter a valid email.',
        pass:         'Please enter passoword, 6-40 characters',
        url:          'Please enter a valid url',
        title:        'Please enter a valid title',
        tweet:        'Please enter a valid tweet',
        empty:        'Please complete all fields',
        same:         'Please make emails equal',
        taken:        'Sorry, that email is taken',
        validate:     'Please contact <a class="d" href="mailto:here@host.com">support</a> to reset your password',
    };
    var Message = function (element) 
    {
        this.element = element;
    };
    Message.prototype.display = function( type ) 
    {
        this.element.innerHTML = messages[ type ];
        new Effects().fade( this.element, 'down', 4000 );
    };
    return Message;
} () );

My entire library is using the module pattern like this

    var NS = ( function ( window, undefined ) 
    {
    /*
    all code here including Message
    */
    } )( window );
  • 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-01T21:50:07+00:00Added an answer on June 1, 2026 at 9:50 pm

    There is no relationship1 to the variable names at all.

    It is just the name used inside. It might as well be fuubar:

    var fuubar = function (element) 
    {
        this.element = element;
    };
    fuubar.prototype.display = function( type ) 
    {
        this.element.innerHTML = messages[ type ];
        new Effects().fade( this.element, 'down', 4000 );
    };
    return fuubar; // the Object is returned, the Variable (Name) is not
    

    It makes sense that the outer name is Message, because that is how it is “known” to others. 1The inner name was likely chosen for consistency, but otherwise does not affect semantics.

    Constructors are just function-objects [designed to be] invoked with the new operator. Variables can name objects. In this case note that it is the function-object that is returned. Thus the function-object is known by the name Message (e.g. “is assigned to Message”) outside. However, a variable is not an object.

    Thus new X() evaluates the expression X, which must evaluate to a function-object, and then uses it as a constructor. (A constructor is just a normal function that expects to be used with new: it may perform initialization and establish a [[prototype]]). The name X is not important except insofar as it must evaluate to a function-object. Consider this equivalent form to show: new (X)(). The expression (X) is evaluated first.

    So, let’s break down the code:

    var Message = (function () {
       // This function is invoked immediately, due to the
       // parenthesis immediately after the FunctionExpression.
       // As noted above the name Message used inside is not important.
       // What *IS* important is that a Constructor, which is just
       // a function-object (which is just an object) is returned.
       // This returned object will be assigned to (the outer)
       // Message variable. That is, it is "named by Message"
       // after the assignment occurs.
    })()
    
    // At this point Message will evaluate to a function-object
    // (a Constructor in particular).
    Message instanceof Function // -> true
    
    // And we can use it to create new messages:
    var messageA = new Message("a")
    var messageB = new Message("b")
    

    Happy coding.

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

Sidebar

Related Questions

I'm really new to LDAP and just got a connection between my php server
I am making simple connection between two table - first one called users has
i made the connection between emulatore and physical device via USB.I had follow the
What are the difference and connection between IFormattable , IFormatProvider and ICustomFormatter and when
I have long-lasting TCP connection between two computers (second not under my control). Second
I would like to create connection between table 1 and table 3 when I
Note : No MFC No ATL Using Visual C++ While attempting a connection between
I'm looking for a protocol to secure a connection between a mobile device and
I'm having a hard time making the connection between testing and code. I could
I have an application where I want to simulate the connection between a device

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.