473,404 Members | 2,137 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,404 software developers and data experts.

Easy accesses to members higher up in object hierarchy

93 64KB
Language is TypeScript (didn't have a specific category).
Say I have a object hierarchy like so:

Expand|Select|Wrap|Line Numbers
  1. let obj = {
  2.   instance_id: "<some uuid>"
  3.   child1:
  4.   {
  5.     child2:
  6.     {
  7.       function log() => console.log(instance_id);
  8.     }
  9.   }
  10. }
  11.  
Is there some clever way of allowing "instance_id" to be accessible to the lower objects without passing them through functions down the hierarchy and such?

Cant store as static (objects are from classes) due to multiple instances of this object.

Would really appreciate some ideas on this. Thanks in advance.
Dec 10 '20 #1
1 2606
dev7060
636 Expert 512MB
Is there some clever way of allowing "instance_id" to be accessible to the lower objects without passing them through functions down the hierarchy and such?

Cant store as static (objects are from classes) due to multiple instances of this object.
I don't use typescript. How about in two steps when the outer object is defined so no undefined is returned. In vanilla js,
Expand|Select|Wrap|Line Numbers
  1. var obj = { var1 : "value"};
  2. obj.var2 = obj.var1;
Dec 13 '20 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: Erik Johnson | last post by:
I quickly browsed through section 9 of the Tutorial, tried some simple Google searches: I'm not readily seeing how to test class type. Given some object (might be an instance of a user-created...
0
by: archway | last post by:
Hi, I would like to build a hierarchy of ProductNode objects like so ProductNode ---Product Node ---ProductNode ------ProductNode ------ProductNode ---ProductNode
100
by: E. Robert Tisdale | last post by:
What is an object? Where did this term come from? Does it have any relation to the objects in "object oriented programming"?
4
by: Dave Veeneman | last post by:
I have an object hierarchy that's several layers deep, and I'm puzzling over how to access an object at any point in the hierarchy, solely by its key. The hierarchy is similar to an...
8
by: Mark Neilson | last post by:
1. What is the best way to make a single instance of my top level class (DLL) internally available to all other members of the assembly? The top level object is where all other access is made in...
2
by: tinman | last post by:
Hi... I would like to achive the following object model in VB.NET.....not too sure how to achieve this but in VB6 I can declare the Project as PublicNotCreatable so as to prevent external...
1
by: tinman | last post by:
Hi.... Would appreciate some advice on how to achieve the following in an OOP manner: Supposed, I have the following object model: Employee | | - - Projects
9
by: Tom Plunket | last post by:
The project I'm currently on makes heavy use of unnamed structures to represent an "object hierarchy" of a sort. E.g. struct BaseObject { int aMember; int anotherMember; // etc.
1
by: Jay Pondy | last post by:
Given the following List(of Position) objects for an ObjectDataSource Position Description EmployeeA FirstName LastName EmployeeB FirstName LastName
0
GaryTexmo
by: GaryTexmo | last post by:
Hi all, I'm going to describe a method of scaling your objects so they fit correctly on your screen no matter what size of canvas you're drawing them on. This is going to be a fairly simple,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.