-
-
Save EtherTyper/3d056339e950ba531875ea231119c42f to your computer and use it in GitHub Desktop.
My Circular Structure testing in JavaScript. https://repl.it/JnYY/0
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const i = {}; | |
i.i = i; | |
console.log(i); | |
function I() { | |
this.i = this; | |
} | |
const functionI = new I(); | |
console.log(functionI); | |
const getterI = {}; | |
Object.defineProperty(getterI, "i", { | |
enumerable: true, | |
get: function returnSelf() { | |
return this; | |
}.bind(getterI), | |
}); | |
console.log(getterI); | |
const circularTest = {}; | |
circularTest.a = {}; | |
circularTest.b = { hello: "hello" }; | |
circularTest.a.b = circularTest.b; | |
circularTest.b.a = circularTest.a; | |
console.log(circularTest); | |
let circularObjects = [i, functionI, getterI, circularTest]; | |
let promises = circularObjects.map(i => { | |
return new Promise((resolve, reject) => | |
resolve(JSON.stringify(i))) | |
.then(console.log) | |
.catch(reason => { | |
console.log(i); | |
console.error(reason); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment