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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T17:21:48+00:00 2026-06-01T17:21:48+00:00

Both these ways work using the same call mechanism. Obviously, I want to use

  • 0

Both these ways work using the same call mechanism.

Obviously, I want to use the best way, but perhaps it is just a matter of preference?

Style-wise I like the Object Literal Notation because it provides enclosure.

Function Notation:

var TextProcessor = function()
{
};
TextProcessor.unEscape = function( second_split )
{
    var element;
    for( element in second_split )
    {
        second_split[element] = second_split[element].replace( '**', '*', 'g' );
        second_split[element] = second_split[element].replace( '|*', '|', 'g' );
    }
    return second_split;
};
TextProcessor.pullBullet = function( text )
{
    var pattern = /<(.+)_([a-z]){1}>$/;
    return pattern.exec( text );
};
TextProcessor.pullDomain = function( text )
{
    return text.match( /:\/\/(www\.)?(.[^\/:]+)/ )[2];
};

Object Literal Notation

/**
 *TextProcessor
 */

var TextProcessor = 
{
    unEscape:    function( text )
    {
        var index;
        for( index in second_split )
        {
            text[index] = text[index].replace( '**', '*', 'g' );
            text[index] = text[index].replace( '|*', '|', 'g' );
        }
        return second_split;
    },
    pullBullet:  function( text )
    {
        var pattern = /<(.+)_([a-z]){1}>$/;
        return pattern.exec( text );
    },
    pullDomain:  function( text )
    {
        return text.match( /:\/\/(www\.)?(.[^\/:]+)/ )[2];
    }
}
  • 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-01T17:21:50+00:00Added an answer on June 1, 2026 at 5:21 pm

    You’re doing two somewhat different things.

    • The first example creates a function object and assigns properties to it.

    • The second example creates a plain object with those properties.

    The first one really doesn’t make much practical sense in your example. You can use a function object to assign properties, but why would you? Those properties have no impact on the invocation of the function.


    “Style-wise I like the Object Literal Notation because it provides enclosure.”

    I don’t know what “enclosure” is. It sounds like a combination of encapsulation and closure, of which an object literal provides neither.


    Getting back to the first part, imagine if you created any one of these objects…

    var TextProcessor = new Number();
    var TextProcessor = new Boolean();
    var TextProcessor = new Date();
    

    …and then assigned the properties to it. It would work, but it would be an odd thing to do. The fact that the object is a Number, Boolean, or Date has little relevance to the task at hand.

    That’s effectively what you’re doing when you assign the properties to a Function object.

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

Sidebar

Related Questions

These 2 ways of working both work, but I'm wondering if there's a difference
I would like to use both of these library on the same page but
Do both these files have the same content? Or do they provide different functionality
I have heard both of these terms used, are they the same thing or
I have an android.graphics.bitmap and an android.net.Uri both of these I can use anyway
I need to access XML files with JQuery. I tried these two ways but
I'm trying to write a python regular expression that will match both these URLs:
I have two excel files. Among many columns in both these files, they have
I am having two android emulators. Let's say emulator1 and emulator2. Both these emulators
Are both of these versions OK or is one of them to prefer? #!/usr/bin/env

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.