Javascript - JSON.stringify - Circular Structure

424 단어 Javascript
    let cache = [];
    let result = JSON.stringify(pool.pool, (key, value) => {
        if (typeof value === 'object' && value !== null) {
            // Duplicate reference found, discard key
            if (cache.includes(value)) return;
            // Store value in our collection
            cache.push(value);
        }
        return value;
    });
    cache = null;

좋은 웹페이지 즐겨찾기