Re: function pointers vs direct calling in javascript

Giganews Newsgroups
Subject: Re: function pointers vs direct calling in javascript
Posted by:  Randy Webb (hikksnotatho…@aol.com)
Date: Tue, 20 Nov 2007

Sampat said the following on 11/20/2007 6:24 PM:
> Hi,
>  I wanted to know the performance of calling a function pointer v/s a
> normal function call in javascript in a scenario where there are
> multiple calls in the js to the same function. Please share your
> thoughts if someone has worked on this.

You don't need testing to figure it out, although testing will prove it.
The function pointer is *always* going to be slower. It has to be slower
since it it doing more than a plain function call. You are telling the
browser "Do this, then do that" versus "do that" and the first will
*always* be slower.

--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ -http://jibbering.com/faq/index.html
Javascript Best Practices -http://www.JavascriptToolbox.com/bestpractices/

Replies

In response to

function pointers vs direct calling in javascript posted by Sampat on Tue, 20 Nov 2007