Writing to a name walks the scope chain exactly like reading does — and when it finds nothing, sloppy mode creates a global while strict mode throws. Write assign(chain, name, value, strict) that does that.
chain is an array of scope objects, innermost first; the last one is the global scope- write
value into the nearest scope that declares name — a scope declares it when it has it as an own property, even holding undefined - if no scope declares it: when
strict is true, throw a ReferenceError; otherwise create it on the global scope