What is an Object Graph and how can it be implemented in my JavaScript code

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • dseals22
    New Member
    • Jan 2017
    • 74

    #16
    @Dormilich Are they just pointing at each other? If so, how can I get my objects to just point at each other?

    Comment

    • Dormilich
      Recognized Expert Expert
      • Aug 2008
      • 8694

      #17
      Are they just pointing at each other?
      object1 has a reference to object2. That is completely different from being identical.

      Comment

      • dseals22
        New Member
        • Jan 2017
        • 74

        #18
        @Dormilich How can I get my object 1 to reference to object 2 that I wrote in my above JS file? Is it possible to do it with my objects?

        Comment

        • Dormilich
          Recognized Expert Expert
          • Aug 2008
          • 8694

          #19
          you got the referencing right, but it's not called 'identity'.

          Comment

          • dseals22
            New Member
            • Jan 2017
            • 74

            #20
            @Dormilich I am sorry for the long extended conversations, but would it be possible to show me with an example of how I can point the objects to one another?

            Comment

            • Dormilich
              Recognized Expert Expert
              • Aug 2008
              • 8694

              #21
              see post #13

              Comment

              • dseals22
                New Member
                • Jan 2017
                • 74

                #22
                @Dormilich I know that was a simple example, but how can it be done using my objects in my JS file. For example with this JavaScript code below:
                var*student1=*n ew*Person("Gray ",*'B',*'F',*3. 34,*5);
                var*student2=*n ew*Person("Jerr y",*'A',*'M',*3 .99,*4);*

                Comment

                • Dormilich
                  Recognized Expert Expert
                  • Aug 2008
                  • 8694

                  #23
                  It makes no sense to reference student1 in student2 or vice versa.

                  Comment

                  • dseals22
                    New Member
                    • Jan 2017
                    • 74

                    #24
                    @Dormilich
                    Not even point to each other. I know it's a stupid question, but that's how I learn. All questions are never stupid only the ones never asked.

                    Comment

                    • jmrker
                      New Member
                      • Dec 2012
                      • 17

                      #25
                      Your post #1 code had too many errors.
                      See what was fixed here and maybe begin your question again (?)
                      Code:
                      <html> 
                       <head>
                        <title></title>
                       </head>
                       <body>
                        <p id= "demo1"> </p>
                        <p id= "demo2"></p>
                      
                      <script>
                      function Person(Name, Grade, Gender, GPA, ClassRank) { 
                        this.Name= Name;
                        this.Grade  = Grade;
                        this.Gender = Gender;
                        this.GPA = GPA;
                        this.ClassRank = ClassRank;
                      }
                      var student1= new Person("Gray", 'B', 'F', 3.34, 5);
                      var student2= new Person("Jerry", 'A', 'M', 3.99, 4); 
                       
                      document.getElementById("demo1").innerHTML =
                       student1.Name + " " + student1.Grade + "* " + student1.Gender + " " + student1.GPA + " " + student1.ClassRank; 
                      document.getElementById("demo2").innerHTML =
                       student2.Name + " " + student2.Grade + "* " + student2.Gender + " " + student2.GPA + " " + student2.ClassRank; 
                       
                      </script>
                      
                       </body>
                      </html>
                      What is it that you are really trying to do?

                      Comment

                      Working...