can local variables inside a sealed object pass information to global variables?

StackOverflow https://stackoverflow.com/questions/18939308

  •  29-06-2022
  •  | 
  •  

سؤال

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

هل كانت مفيدة؟

المحلول

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.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top