Question

Not sure if I'm wording this correctly but can local variables inside a sealed object pass information to global variables?

Était-ce utile?

La solution

Yes, they can:

var hello = 0, obj;

obj = {
  foo: function () {
    hello = 3;
  }
};

Object.seal(obj);

console.log(hello); //logs 0
obj.foo();
console.log(hello); //logs 3

Here's a jsfiddle.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top