Suppose I create an object factory like so:
var newObj=function(x){
var obj=[]
obj.x=x
obj.add=function(n){
return this.x+n
}
return obj
}
Now suppose I create hundreds of instances of this object:
var obj1=newObj(1)
var obj2=newObj(2)
...
Does each obj1,obj2,... store their own copy of obj.add or do they all contain a reference to a single instance of obj.add stored in memory?
Thanks!