Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Agile forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

need to understand reference

 
simon tiberius
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

in my understanding:
1. DOM element is equivalent to JS object. correct?
2. there's only one JS object in this case, the button with id "element". correct?
3. obj (line 5) is not a javascript object. it's just a pointer to button with id "element". is this correct?
4. where in the code (what line) that shows DOM element also have reference to JS object?
thanks
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64623
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
simon tiberius wrote:
1. DOM element is equivalent to JS object. correct?

Each DOM element is a JavaScript object.

2. there's only one JS object in this case, the button with id "element". correct?

No. There are many objects. But all you created a variable reference to was the button element object.

3. obj (line 5) is not a javascript object. it's just a pointer to button with id "element". is this correct?

Variables are just references to objects.

4. where in the code (what line) that shows DOM element also have reference to JS object?

I don't know what you are asking here.
 
simon tiberius
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks for the reply.
I need to confirm, obj itself is not an object right? just storing a reference to an object (which in this case is the button)
as for question number 4, I read a tutorial that the code has a circular reference where DOM element (I assume the article was referring to button element) also refers to obj. This is what confuses me. So I need to know what line of code showing reference to obj.
I quote from the article:
you see a JavaScript object (obj) contains a reference to a DOM object (referenced by the id "element"). The DOM element, in turn, has a reference to the JavaScript obj
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic