我试过:
const state = new Set( [5, 10, 15, 20, 30, 45, 60] );
let preset = Object.assign( {}, state );
console.log(preset)
// {}
Run Code Online (Sandbox Code Playgroud)
并得到空对象。我也尝试将状态转换为字符串,但也失败了:
state.values().toLocaleString()
// "[object Set Iterator]"
Run Code Online (Sandbox Code Playgroud)
还是只能一一迭代Set?
更新:结果应该是一个值数组:[5, 10, 15, 20, 30, 45, 60]。