How to store Set object in chrome local storage
问题 var testSet = new Set(); testSet.add(1); testSet.add(2); chrome.storage.local.set( { 'key': testSet }, function() { chrome.storage.local.get( 'key', function(data){ console.log(data) }); }); This outputs Object {key: Object} key: Object__proto__: Object__proto__: Object Why doesn't it show the testSet values in there? 回答1: One way to achieve this, is by converting your Set into an array by using Spread Operator. E.g. var testSet = new Set(); testSet.add(1); testSet.add(2); chrome.storage