It's not a secret anymore!*
The moose likes HTML, CSS and JavaScript and the fly likes need to understand reference Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "need to understand reference" Watch "need to understand reference" New topic
Author

need to understand reference

simon tiberius
Greenhorn

Joined: Oct 30, 2012
Posts: 29

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

Joined: Jan 10, 2002
Posts: 60046
    
  65

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.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
simon tiberius
Greenhorn

Joined: Oct 30, 2012
Posts: 29
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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: need to understand reference
 
Similar Threads
Zooming Image Problem
Problem with custom events in jQuery
Is there something better then event.pageX/Y?
How to refresh DIV
Not able to add submit button in HTML using jquery