If We have
var randomname = {};
randomname.attribute = \'something\';
function randomname(){
alert(randomname.attribute);
}
randomname();
function randomname(){
alert(randomname.attribute);
}
is roughly the same as this:
var randomname = function() {
alert(randomname.attribute);
}
It's not 100% identical, since with the first syntax you can refer to functions "in the future", but this is basically how it works. There is only once namespace for functions and variables, since functions get assigned to variables.