SitePoint Sponsor |
|
User Tag List
Results 1 to 2 of 2
-
Jun 30, 2008, 08:07 #1
- Join Date
- Dec 2007
- Posts
- 1
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
syntax question re calling function in an object
I am learning much from the Simply Javascript book - now in the chapter about events. I have a simpleminded question - when you call an isolated funcition you use parenthesis after the name of the function: e.g. dothisfunction()
It seems that when the funtion is a method inside of an object you leave out the parenthesis - quoting from page 108 of the book I see:
link.onclick = wikipediaLink.clickHandler;
rather than:
link.onclick = wikipediaLink.clickHandler();
Am I correct and can anyone explain why?
Many thanks for any clarification.
-
Jun 30, 2008, 08:35 #2
- Join Date
- Dec 2007
- Posts
- 358
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Function itself is an object so
Code:link.onclick = wikipediaLink.clickHandler;
Code:link.onclick = wikipediaLink.clickHandler();
Bookmarks