Skip to content

Instantly share code, notes, and snippets.

@woodyrew
Created December 4, 2017 10:47
Show Gist options
  • Save woodyrew/55b0408cad0f88a72593e8c16966caaa to your computer and use it in GitHub Desktop.
Save woodyrew/55b0408cad0f88a72593e8c16966caaa to your computer and use it in GitHub Desktop.
Circular references
const posts = {
'first': {
title: 'first'
},
'second': {
title: 'second'
},
'third': {
title: 'third'
}
};
posts.first.next = posts.second;
posts.second.previous = posts.first;
posts.second.next = posts.third;
posts.third.previous = posts.second;
console.log(posts);
/*
posts: {
first:
{ title: 'first',
next: { title: 'second', previous: [Circular], next: [Object] }
},
second:
{ title: 'second',
previous: { title: 'first', next: [Circular] },
next: { title: 'third', previous: [Circular] }
},
third:
{ title: 'third',
previous: { title: 'second', previous: [Object], next: [Circular] }
}
}
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment