Suppose we have an object foo
var foo = {
x: 0
}
And we add a function fx to it like this:
foo.fx = function() {do_something(this.x)}
If we do this process in a loop or in a function call for multiple times, does the JavaScript engine create that fx function multiple times or does it create the function for once and just change address of this?
e.g
function objectMaker() {
function fx() {
this.x += 1;
}
var foo = {
x: 0,
fx: fx
}
return foo;
}
Does the objectMaker function always allocate memory for fx method or does it create it only once?

