JavaScript closures and methods

In the following case:

var o1 = {}
var o2 = {}

o1.a = function a() {}
o2.b = function b() {
  o1.a()
}

      

Does it close o2.b

" o1

or just a function reference o1.a

?

I doubt this has a big performance or memory impact, especially considering that we do this with the global scope all the time, but I'm just curious.

+3


source to share


1 answer


Just a link. This particular call will have scope access o2.b()

, but if you call o1.a()

somewhere else, it will also access the scope of whatever you put at that time (global or close).



-1


source







All Articles