Converting circular structure to JSON
const getCircularReplacer = () => {
const seen = new WeakSet();
return (key, value) => {
if (typeof value === "object" && value !== null) {
if (seen.has(value)) {
return;
}
seen.add(value);
}
return value;
};
};
JSON.stringify(circularReference, getCircularReplacer());
//The error means that the object you pass in the request has a circular reference, something like:
var a = {};
a.b = a;I also ran into this issue. It was because I forgot to await for a promise.Game.prototype.restart = function () {
this.clearLocalStorage();
this.timer = setTimeout(this.reset.bind(this), 0); // bind to 'this'
};
Game.prototype.reset = function(){
this.clearBoard(); // ahhh, back in the context of the right 'this'!
};
Also in JavaScript:
- remove element json javascript
- expo react native
- video js toggle play pause
- conditional rendering alert if input fields are empty
- js url encode
- find length of longest string in array javascript
- how to select the first div in jQuery
- how to get data in json format in javascript
- javascript loop over classlist
- js navigate to another page
- react native setstate object
- how to print NODE_PATH
- react native scrollview
- javascript popup function
- nodejs bodyparser form data
- Warning: Failed child context type: Invalid child context `virtualizedCell.cellKey` of type
- set navigation drawer to open by default react native
- javascript get element position relative to document
- split the numbers js
- react navigation stack
- pug to html
- sum of odd numbers in an array javascript
- js class private
- $(this) option selected jquery