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

  • Home
  • SEARCH
  • 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 8853239
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T13:36:12+00:00 2026-06-14T13:36:12+00:00

I understand why : output = new Array(); and output = []; but why

  • 0

I understand why :

 output = new Array();

and

 output = [];

but why does this work?

 output = Array();
  • 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-14T13:36:13+00:00Added an answer on June 14, 2026 at 1:36 pm

    The Array() constructor is simply implemented such that calling it with new is unnecessary. It’s part of its semantic definition.

    Built-in constructors like Array() are (probably) not written in JavaScript, but you can get the same effect in your own code:

    function MyConstructor() {
      "use strict";
      var newObj = this || {};
    
      // ...
    
      return newObj;
    }
    

    When you invoke with new, the constructor will see that’s it’s got something bound to this. If you don’t, then this will be undefined (because of “use strict”; you could alternatively check to see whether this is the global object, which you’d have to do for old IE).

    The return value from a constructor is not the value of a new expression – that’s always the newly-created object. When you call it without new, however, the return value will be used.

    edit — RobG points out in a comment that for this to really work properly, the “synthetic” newObj that the function creates needs to be explicitly set up so that it’s got the proper prototype etc. That’s kind-of tricky; it might be simplest for the code to simply do this:

    function MyConstructor() {
      "use strict";
      if (!this) return new MyConstructor();
      // ... or possibly using "apply" if you need parameters too
    }
    

    T.J. Crowder has written some awesome answers here on the subject of object/inheritance wrangling.

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

Sidebar

Related Questions

I don't understand the output of this program: int arr[]={1,7,4,2,5,8}; int x=(&(arr[arr[1]-arr[4]])-arr); printf(%d ,x);
I understand the way Mealy state machines work - the output logic is now
I understand this is an easy question but for some reason this just isn't
I really dont understand the output of my array. In the start it seams
From what I understand, the output from the following script should include Win32_PerfRawData_PerfDisk_PhysicalDisk in
Greetings P4 folks, I am trying to understand the P4 describe -ds output. I
Premise: I'm not trying to reinvent the wheel, I'm just trying to understand. Output
System.out.println(1+2+3); System.out.println(1+2+3); output:- 33 123 First case is understood but the second case is
I'm not quite understand why does Object.GetHashCode() return different values for two identical byte
Please help me understand the following: I create a CharBuffer using CharBuffer.wrapped(new char[12], 2,

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.