I have a simple question about cycles references in javascript.
Is this a cycle reference?
var theThing=null;
theThing = {
longStr: new Array(1000000).join('*'),
someMethod: function () {
console.log(someMessage);
}
someMethod context captures theThing variable right?
Example 2:
var theThing = null;
var replaceThing = function () {
var originalThing = theThing;
theThing = {
longStr: new Array(1000000).join('*'),
someMethod: function () {
console.log(someMessage);
}
};
};
setInterval(replaceThing, 1000);
In example 2, is there an cycle reference? SomeMethod references originalThing which is the Thing.