What is the difference between this:
var doSomething=function()
{
//do blah blah blah...
}
And this:
function doSomething()
{
//do blah blah blah...
}
Another question: In PHP, we create a function by doing this:
function doSomething(a,b)
{
//do something to variable a and b...
}
In JavaScript, we may have an object before the function:
object.doSomething(a);
My second question is, how would you create a function which requires an object in JavaScript?
The number one Google result for "function statement vs expression javascript" is another Stack Overflow question:
What is the difference between a function expression vs declaration in JavaScript?
It references the following article, which is the definitive reference on the subject:
http://kangax.github.com/nfe/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With