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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T07:27:51+00:00 2026-05-31T07:27:51+00:00

In terms of performance and the data structure created, is: function coords(xpos, ypos, zpos){

  • 0

In terms of performance and the data structure created, is:

function coords(xpos, ypos, zpos){
    this.xpos = xpos;
    this.ypos = ypos;
    this.zpos = zpos;
    return this;
}
var coordinates = coords(0, 0, 0); // notice I am not calling new

The same as:

function coords(xpos, ypos, zpos){
    return {
        xpos : xpos,
        ypos : ypos,
        zpos : zpos, 
    };
}
var coordinates = coords(0, 0, 0);

Is there are more performant way of generating the coordinates assuming I have a lot of them.

  • 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-31T07:27:53+00:00Added an answer on May 31, 2026 at 7:27 am

    In the first approach for creating an object you have to use

    var coordinates = new coords(0, 0, 0); and in javascript using new is expensive. In the second approach executing the function will return you a coordinate object.

    I prefer the second approach though it doesn’t make much difference in modern browsers.

    here is a simple benchmark http://jsperf.com/objecr-vs-fn-perf-test

    in Firefox 7 the first approach is ~75% slower than second and in chrome 17 it si ~30% slower

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

Sidebar

Related Questions

What's the best in terms of speed and performance? To call the function each
In terms of performance. Is it a good idea to build your own data
Is it OK to reuse variables for different data types in terms of performance
I'm having this big dilemma for my project in terms of performance. I have
Are there any data mining algorithms comparisons? Comparisons in terms of performance, accuracy and
In terms of performance and efficiency, is it better to use lots of small
what is the best solution in terms of performance and readability/good coding style to
What is a better option (in terms of performance): copying a file using fileinputstream
I recall having read somewhere that it is better (in terms of performance) to
Which method is better and why, when? In terms of scalability,performance etc which one

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.