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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T03:12:07+00:00 2026-05-31T03:12:07+00:00

i came across this post http://www.webmasterworld.com/javascript/3066162.htm about how in javascript when you instantiate an

  • 0

i came across this post http://www.webmasterworld.com/javascript/3066162.htm
about how in javascript when you instantiate an object literal if it has methods defined in it then each time one is instantiated its methods are copied as well. so if you have a bunch of instances of the object literal then the copied methods would begin to add up in memory.

how ever he/she states that using prototype to make your methods is more efficient because the methods are not copied for each instance of the constructor object.

is this true? because i was under the impression that prototype allowed you to add properties/methods even after the object was instantiated rather than within the object when its first created.

  • 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-31T03:12:08+00:00Added an answer on May 31, 2026 at 3:12 am

    It is true, that is why there is a prototype.

    // define Function foo
    function Foo()
    {
        this.x = 1;
        this.bar = 'bar';
    }
    
    // define method on Foo's prototype
    Foo.prototype.helloBar = function()
    {
        alert(this.bar);
    }
    
    
    var foobar = new Foo();
    
    foobar.helloBar(); // alerts "bar"
    

    Using Foo.prototype prevents the unnecessary extra bits associated with redefining hellobar for every instance new Foo().

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

Sidebar

Related Questions

While stumbling through the chromium code documentation, I came across this post: http://code.google.com/p/chromium/wiki/UsingGit#Windows If
While browsing I came across this blog post about using the Wikipedia API from
I came across this post on the MSMobiles.com blog that says the following, among
I just came across this post that talks about time measuring. I remember (I
I recently came across this post on Forrst: http://forr.st/~Nbp and thought it'd be a
I was reading this blog post: http://www.shakie.co.uk/ramblings/feature-driven-development-riding-the-waves-of-change/ and came across the part about TestDox:
Well I was reading this post and then I came across a code which
Kicking around some small structures while answering this post , I came across the
I've recently came across a blog post about how you can use Photoshop PDF
It's easy! I just came across this blog post by Rudi Grobler that says

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.