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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T01:25:52+00:00 2026-05-26T01:25:52+00:00

i’m trying to figure out how much i can use of the javascript language

  • 0

i’m trying to figure out how much i can use of the javascript language itself and how much i would have to implement myself when it comes to object reflection. here’s the intended result

// property inheritance schema (defining default props) (stored in db "schemas" table)
foo
    bar
        moo
    baz
        ugh

// method inheritance schema (stored in code)
foo
    bar
        moo
    baz
        ugh

// myTree structure + property overrides (stored in db "structs" table)
myBar
    myBaz
    myUgh
        myBar
    myBaz
        myMoo

an instance of a Tree object will be constructed from the myBar structure. when building each node, it will compose the methods from the code, with the “inherited” property schema and any non-default properties from the node defined in the myBar struct itself.

the goal is to create a a system that, given a node from an instance of Tree, can self-analyze its own property inheritance path and identify at which level the property is defined.

this is to allow editing of the myBar structure and indicate which properties are inherited as defaults from the base schema (and at which level) and which ones are explicitly defined in the myBar structure.

the question is, how much can be determined from recursively analyzing the .constructor and .prototype properties using JS, and how much would need to be custom implemented?

i’m not sure if this is sufficiently clear, so please ask for any clarification.

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-05-26T01:25:52+00:00Added an answer on May 26, 2026 at 1:25 am

    You want to build prototype chains.

    So let’s say your chain of inheritance is

    foo -> bar -> moo.

    Then you have an object Foo that is your prototype for foo nodes.

    You can create a Bar object by simply injecting Foo into it’s prototype chain.

    var Bar = Object.create(Foo, props)

    Now we have a Bar prototype that is the prototype for bar nodes.

    Then you do the same for Moo

    var Moo = Object.create(Bar, props)

    Now let’s say you have a moo node.

    Then you can simply take any property that you know. Let’s call it “prop1” and write a simple function which gives you the object the property belongs to

    var findPropertyOwner = function(obj, prop) {
      do {
        if (obj.hasOwnProperty(prop)) {
          return obj;
        }
      } while (obj = Object.getPrototypeOf(obj));
    }
    

    Now one of the issues that you may face is that the obj in the prototype chain has no meta data telling you what the object is so you may want to add a property "name" to all your node prototype objects so that you can more easily check what it is.

    You may also want to have findPropertyOwner return a tuple of (obj, count) as follows

    var findPropertyOwner = function(obj, prop) {
      var i = 0;
      do {
        if (obj.hasOwnProperty(prop)) {
          return [obj, i];
        }
      } while (i++, obj = Object.getPrototypeOf(obj));
    }
    

    This way you have more information like how far up the prototype chain that property was found. Also note that when the do/while loop terminates (Object.getPrototypeOf(Object.prototype) === null) it will return undefined

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

Sidebar

Related Questions

I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
I am trying to understand how to use SyndicationItem to display feed which is
I have a jquery bug and I've been looking for hours now, I can't
I am trying to loop through a bunch of documents I have to put
I'm trying to use string.replace('’','') to replace the dreaded weird single-quote character: ’ (aka
Basically, what I'm trying to create is a page of div tags, each has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and

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.