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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T02:35:34+00:00 2026-05-24T02:35:34+00:00

Probably the least understood part of JavaScript, standing beside the prototype chain. So the

  • 0

Probably the least understood part of JavaScript, standing beside the prototype chain.

So the question is: how does…

new dataObj(args); 

…actually create an object, and define its prototype chain/constructors/etc?

Best is to show an alternative, to fully understand this keyword.

  • 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-24T02:35:35+00:00Added an answer on May 24, 2026 at 2:35 am

    The new operator uses the internal [[Construct]] method, and it basically does the following:

    • Initializes a new native object
    • Sets the internal [[Prototype]] of this object, pointing to the Function prototype property.
      • If the function’s prototype property is not an object (a primitive values, such as a Number, String, Boolean, Undefined or Null), Object.prototype is used instead.
    • After creating the object, it calls the function, providing the object as its this value.
    • If the return value of the called function, is a primitive, the object created internally is returned.
    • Otherwise, if an object is returned, the object created internally is lost.

    An equivalent implementation of what the new operator does, can be expressed like this (assuming that the ECMAScript 5 Object.create method is available):

    function NEW(f) {
      var obj, ret, proto;
    
      // Check if `f.prototype` is an object, not a primitive
      proto = Object(f.prototype) === f.prototype ? f.prototype : Object.prototype;
    
      // Create an object that inherits from `proto`
      obj = Object.create(proto);
    
      // Apply the function setting `obj` as the `this` value
      ret = f.apply(obj, Array.prototype.slice.call(arguments, 1));
    
      if (Object(ret) === ret) { // the result is an object?
        return ret;
      }
      return obj;
    }
    
    // Example usage:
    function Foo (arg) {
      this.prop = arg;
    }
    Foo.prototype.inherited = 'baz';
    
    var obj = NEW(Foo, 'bar');
    obj.prop;          // 'bar'
    obj.inherited;     // 'baz'
    obj instanceof Foo // true
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Probably a long question for a simple solution, but here goes... I have a
Probably a bit off topic question, but it's something I'm really interested in getting
Probably a noob question, but I'll go for it nevertheless. For sake of example,
Probably a dumb question, but is it still using Include files?
This probably sounds like a stupid question, but I'm going to give it a
Relatively new to mySQL so this is probably an easy one: I have a
I'm pretty new to Objective-C. I've read through a similar question but I can't
Probably a really simple one this - I'm starting out with C# and need
Probably an easy one: Are there any rules of thumb or pointers that could
Probably not much more to elaborate on here - I'm using a NumericStepper control

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.