class ren{
nn:string
next:ren
constructor(nn){
this.nn = nn
}
}
let rr = new ren("eee")
rr.next = new ren("ggg")
rr.next.next = new ren("ooo")
rr.next.next.next = new ren("jjj")
rr.next = rr.next.next
let xx = new ren("fff")
xx.next = rr.next
rr.next = xx
while(rr){
document.write(rr.nn)
rr = rr.next
}