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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T10:40:38+00:00 2026-06-07T10:40:38+00:00

I am new here so I hope I do not violate any rules… It

  • 0

I am new here so I hope I do not violate any rules…

It is so that I am working on object inheritance in JavaScript… and are figuring out “my” rules for this thing… And now I have come to “some” sort of a problem…

this is what I like to do:

I like to have an method (function) that is more an identifier for the object I am creating, this method is also the objects creator… However I also wish to use that same object to instantiate the “datatype” the object created (I guess code explains more so… here is the piece I am stuck with)

    TRecord = function() {
      this.Class = 'TRecord';
      F = function() {};
      F.prototype = arguments[0]; //args is an object (se below)
      return(new F());
    };

    TRecord.create = function(O) { // this method will not be executed as I like
        if(O) alert(O.Class);      // inside above object when define there with
        <new O object created and returned - code missing>
    };                             // this.create = function(){};
                                   // but if defined here it will, se below...

    TMessage = TRecord({
      'Class': 'TMessage',
      'msgID': Number(0),
      'data': Object('Hello')
    });

    aMSG = TRecord.create(TMessage); // the TMessage instance will be created
                                     // with the above method... and
    alert(aMSG.Class);               // will output TMessage...

why can’t I implement the TRecord.create function inside TRecord ?

…
I have some trouble posting the whole source.js (the formatting do not work) so this will have to due, I do however have some other constructors/creator functions for “real” function (class) objects and not records (data objects)… that works – these are Implemented a bit different though, with support for deep inheritance…

  • 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-07T10:40:40+00:00Added an answer on June 7, 2026 at 10:40 am

    The this keyword refers to the scope under which a function is called. In your example:

    TMessage = TRecord({...});
    

    TRecord will be called with the global or window object as its scope, or in strict mode, undefined. The this keyword only refers to a new object inside of a constructor function because of how the new keyword boxes a call with the new scope.

    For more information, please see https://developer.mozilla.org/en/JavaScript/Reference/Operators/this

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

Sidebar

Related Questions

I'm new here same as I'm new with assembly. I hope that you can
I am new here, but I am having hard time figuring out how to
I'm new here and I hope I'm not asking something which has already been
I'm very new to xml so I hope I'm not asking any silly question
Sorry, still reasonably new to Javascript here, so hope this question isn't too embarrassingly
I'm new here and I'm also not much of a programmer but I hope
I am new here and hope my first question meets stack overflow's requirements. I
I'm new here and I hope anyonte can help me. I have WCF Service
I'm new here and I hope I could get some help with an Android
hello i am new here and i hope i don`t post in a wrong

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.