views:

76

answers:

5

I'm reading the Google Maps API and it states that the:

"callback: The function to call once the script has loaded. If using the Auto-loading feature, this must specify a function name, not a function reference.

What's the difference been a JavaScript function name vs a function reference?

http://code.google.com/apis/ajax/documentation/#GoogleLoad

A: 
Pointy
so it would be *callback=function_name* or *callback=function_name()* ?
Teddyk
Neither: `{callback: "function_name"}`
Pointy
+1  A: 

A function name is a string ("alert"). A function reference is the function itself (alert).

Ignacio Vazquez-Abrams
so it would be *callback="function_name"* ?
Teddyk
If you're using auto-loading.
Ignacio Vazquez-Abrams
Yes, I'm using auto-loading. So is * callback="function_name"* correct?
Teddyk
If you're using auto-loading.
Ignacio Vazquez-Abrams
Any idea why *http://www.google.com/jsapi?autoload={modules:[{name:%22maps%22,version:3,{other_params:%22sensor=false%22,callback:%22function_name%22}]}* doesn't work then?
Teddyk
A: 

function: func() {}

function reference: func

function name: 'func'

ykaganovich
+1  A: 

The name of a function is a string such as 'foo' in this case:

function foo() {}

A reference to a function is any variable that is set to the value of the function itself (not the result of calling it).

Functions in Javascript can be anonymous - you can have a reference to a function that has no name.

var bar = function() {}
Mark Byers
A: 

Nothing.

// f1 :: function name
function f1(a) { return a*a; }  

// f2 :: reference to an anonymous function
var f2 = function(a) { return a*a; }  

// f3 :: a reference to the first function
var f3 = f1; 

// these are equivalent. The second one calls into 
// a different actual function. 
f1(3);  // 9
f2(4);  // 16
f3(5);  // 25
Cheeso
The question makes sense if you read the snippet of documentation in context.
Pointy
I understand. . .
Cheeso