This seems rather obvious to me, but I just wanted to make sure. In terms of memory used when the foo
function is stored, would it better to do this:
function foo(){
var hey = {};
hey.a = 1;
hey.b = 1;
alert('done');
}
or
function foo(){
var hey = getHey();
alert('done');
}
function getHey(){
var hey = {};
hey.a = 1;
hey.b = 1;
return hey;
}
Since getHey()
is just going to be a reference to the actual function, I'm not sure whether it stores foo
as is, or with an embedded getHey
.