Why does the following work:
function outsideFunction() {
return {
insideFunction: insideFunction
}
function insideFunction() {
...stuff
}
}
isn't
function insideFunction() {
...stuff
}
the same as
var insideFunction = function() { ...stuff }
which would cause var insideFunction
to be hoisted to the top?
Shouldn't insideFunction
return undefined
when used in the object declaration?
Can I do the same thing with an object? In other words, can I do:
return {objectName: objectName}
var objectName = {}