A function sees whatever variables were around when it was created.
Here, get and set were created within the same call to
assignAccessors, so they see the same x.
var get, set; function assignAccessors() { var x = 1; get = function() { return x; } set = function(y) { x = y; } }
assignAccessors(); log(get()); set(10); log(get());