📜  javascript 将对象包装在数组中 - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:02:19.230000             🧑  作者: Mango

代码示例1
const anObj = {name: "Hi"};
const anArr = [{name: "Hi"}];

const wrapped1 = [anObj].flat() 
const wrapped2 = [anArr].flat() 

console.log(wrapped1);  // wrapped1 is [{name: "Hi"}]
console.log(wrapped2);  // wrapped2 is [{name: "Hi"}]