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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T22:00:21+00:00 2026-06-14T22:00:21+00:00

Typically, in a constructor function, the object that is bound to this within the

  • 0

Typically, in a constructor function, the object that is bound to this within the function is returned by it when it is called with the new prefix. But I would imagine that it’s also possible (I think I even read this in crockford’s book) to manually return your own value. Are there any places where such a practice is useful?

  • 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-14T22:00:22+00:00Added an answer on June 14, 2026 at 10:00 pm

    If you return a value type from the constructor, you’ll get different behavior depending on if new was used. That’s how String works. Look at this object in your JavaScript console:

    {
        s: String("abc"),
        S: new String("abc")
    }
    

    Little s contains a string value, but big S contains a string Object. A subtle difference, perhaps.

    You could go way beyond that and use the same function for different purposes:

    function Foo() {
        return "abc";
    }
    Foo.prototype.DoSomething = function () {
        // something completely unrelated to "abc"
    };
    var a = Foo();      // The string "abc".  Does not have a DoSomething() method.
    var b = new Foo();  // An Object with a DoSomething() method.  Doesn't know about "abc".
    

    Depending on whether new was used, you’d get back something completely different.

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

Sidebar

Related Questions

Typically you start a service like this Intent i = new Intent(context,MessageService.class); context.startService(i); but
Typically if we just use alert(object); it will show as [object Object] . How
Typically, I've seen people use the class literal like this: Class<Foo> cls = Foo.class;
Typically views appear to output anchors without 'title' attributes. How would you add 'title'
I've typically gotten used to implementing a singleton pattern in this manner because it's
From time-to-time I would like to manually set up an object. Some of my
I know that a certain object is only ever created as a temporary object
Okay, so the book says: when creating a new object, you can pass a
Using PHP5.3.3, I have 2 classes, called SinglePDO and Manager , both working, but
I have vectors of data that I feed through the filter() function -- said

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.