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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T09:29:06+00:00 2026-06-14T09:29:06+00:00

I feel a bit dump but there is something I don’t understand (or even

  • 0

I feel a bit dump but there is something I don’t understand (or even know if it’s possible) about prototyping in JavaScript.
I’d like to use a method while I’m creating the prototype of my pseudo-class :

var Class = function() {}
Class.prototype = {
    a: function() {
        return 'ok'
    }
  , z: Class.prototype.a() // I tried with `this`/`constructor`/etc.
} // TypeError: Object [object Object] has no method 'a' the rest isn't evaluated
var test = new Class()
test.z

I know I can do it this way but I’d like to know if I can still but all my method/properties in the Class.prototype declaration :

var Class = function() {}
Class.prototype.a = function() {
    return 'ok'
}
Class.prototype.z = Class.prototype.a()
var test = new Class()
test.z // "ok"

Thanks.

  • 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-14T09:29:07+00:00Added an answer on June 14, 2026 at 9:29 am

    No, you can’t. Just like you can’t refer to any object properties before the statement that defines them has ended:

    var x = {
        y: 10,
        z: x.y + 5 // TypeError, cannot read property `y` of undefined
    };
    

    The variable x does not have a value (it is declared, since declarations are hoisted, but it’s value is undefined) until the assignment expression in its entirety has been evaluated.

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

Sidebar

Related Questions

This is probably a very basic R question...and feel a bit bad about asking...but
I feel a bit silly for this one, but is there a more elegant
I feel a bit stupid but this is not working (and I expected it
I still feel a bit unsafe about the topic and hope you folks can
Okay, I feel a bit foolish for having to ask this but I guess
I feel a little bit silly asking this, but I haven't been able to
Started learning Wicket after ASP.NET MVC and feel a little bit confused about managing
Ok, I feel a bit dumb having to ask this. There are any number
I feel a bit embarrassed for asking this but here goes: I'm using Excel
I feel a bit absurd asking this but I can't find a way to

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.