I was wondering if anyone has a good, working example of a circular reference in javascript? I know this is incredibly easy to do with closures, but have had a hard time wr
function circular(arg){
var count = 0;
function next(arg){
count++;
if(count > 10) return;
if(arg){
console.log('hava arg: ' + arg);
next();
}else{
console.log('no arg');
next('add');
}
}
next();
}
circular();
Circular and with a closures.
Or using ES6:
class Circular {
constructor() {
this.value = "Hello World";
this.self = this;
}
}
circular = new Circular();