Linked Questions
637 questions linked to/from var functionName = function() {} vs function functionName() {}
512
votes
5
answers
172k
views
What is the difference between a function expression vs declaration in JavaScript? [duplicate]
What is the difference between the following lines of code?
//Function declaration
function foo() { return 5; }
//Anonymous function expression
var foo = function() { return 5; }
//Named function ...
107
votes
8
answers
80k
views
Declaring functions in JavaScript [duplicate]
What's the difference between these two ways of declaring a function?
function someFunc() { ... }
var someFunc = function() { ... }
I'm not asking in the technical sense. I'm not asking which is ...
71
votes
4
answers
36k
views
Are named functions preferred over anonymous functions in JavaScript? [duplicate]
Possible Duplicate:
JavaScript: var functionName = function() {} vs function functionName() {}
There are two possible methods for pulling out a function in Javascript:
var foo = function() { ... }...
58
votes
7
answers
18k
views
The difference between the two functions? ("function x" vs "var x = function") [duplicate]
Possible Duplicate:
JavaScript: var functionName = function() {} vs function functionName() {}
What's the difference between:
function sum(x, y) {
return x+y;
}
// and
var sum = function (x, ...
48
votes
5
answers
41k
views
What does it mean when a variable equals a function? [duplicate]
Possible Duplicate:
JavaScript: var functionName = function() {} vs function functionName() {}
In JavaScript, what's the purpose of defining a variable as a function? I've seen this convention ...
33
votes
3
answers
10k
views
Is there any difference between var name = function() {} & function name() {} in Javascript? [duplicate]
Possible Duplicate:
JavaScript: var functionName = function() {} vs function functionName() {}
Suppose we are inside a function and not in the global namespace.
function someGlobalFunction() {
...
50
votes
1
answer
33k
views
Javascript Function Definition Syntax [duplicate]
Possible Duplicate:
JavaScript: var functionName = function() {} vs function functionName() {}
Declaring functions in JavaScript
I've seen 2 different syntaxes for defining functions in ...
31
votes
2
answers
25k
views
whats the difference between function foo(){} and foo = function(){}? [duplicate]
Possible Duplicate:
JavaScript: var functionName = function() {} vs function functionName() {}
are they the same? I've always wondered
31
votes
5
answers
2k
views
Know JavaScript Function Expression vs Function Declaration, but what is this? Named Function Expression? [duplicate]
Possible Duplicate:
JavaScript: var functionName = function() {} vs function functionName() {}
What is the difference between a function expression vs declaration in Javascript?
I am aware of ...
22
votes
2
answers
36k
views
window.postMessage not working from iframe to parent document [duplicate]
I'm trying to send a simple message from a child document (an iframe) back to its direct parent using the window.postMessage API.
Within the parent document I have the following:
window....
27
votes
3
answers
2k
views
"Usual" functions vs function variables in JavaScript [duplicate]
Is there any difference between
function MyFunc() {
// code...
}
and
var MyFunc = function() {
// code...
};
in JavaScript?
8
votes
5
answers
29k
views
Why window.addEventListener does not work? [duplicate]
On the window.onload event, I would like a function to be called.
If I define it as given below, the function does not get called.
try {
window.addEventListener("load", initialiseTable, false);
}...
4
votes
2
answers
1k
views
What is the point of using a named function expression? [duplicate]
I'm going through this blog about the difference between function declarations and function expressions.
It gives these two examples. They call the first an "anonymous function expression" and the ...
3
votes
1
answer
2k
views
Beginner Javascript: What's the difference between 'function xyz(){}' and 'var xyz = function(){}'? [duplicate]
Possible Duplicate:
JavaScript: var functionName = function() {} vs function functionName() {}
I've been going through CodeAcademy's Javascript courses, and a few things have gone over my head. I ...
JVG's user avatar
- 21.3k
4
votes
6
answers
770
views
What's the difference between this two ways of defining a function in JavaScript? [duplicate]
Possible Duplicate:
Javascript: var functionName = function() {} vs function functionName() {}
Way 1:
function fancy_function(){
// Fancy stuff happening here
}
Way 2:
var fancy_function = ...