This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes HTML, CSS and JavaScript and the fly likes x.someFunction.call(x) Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "x.someFunction.call(x)" Watch "x.someFunction.call(x)" New topic
Author

x.someFunction.call(x)

steve claflin
Ranch Hand

Joined: Dec 04, 2008
Posts: 54
I see a lot of online code using this structure, most notably in references to Ajax in Action, in particular; things like: While I understand how call works, what I can't figure out is why it is needed in this situation.

The code in my subject line seems to me to be exactly the same in effect as:
It would make sense to me if it were:
Am I missing something here?
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60794
    
  65

From what you've posted, the need for call() in this case is unnecessary. It's not wrong, just unnecessarily wordy.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
Trying to remember the exact code since I do not have it in front of me, but I think it is actually needed in that situation since this.onerror can be set in a different scope since it can be a reference to an outside method. It has been awhile since I looked at Dave's Ajax stuff.

Eric

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: x.someFunction.call(x)
 
Similar Threads
JSP_getProperty
compilation error for EVAL_BODY_AGAIN
How to get the url of the page causing the 404 in custom error.jsp?
Issue with JTabbedPane
java.lang.ClassCastException: Model.Employee cannot be cast to Model.Employee