Answers for "javascript wrap object in array"

0

javascript wrap object in array

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"}]
Posted by: Guest on October-23-2021

Code answers related to "javascript wrap object in array"

Code answers related to "Javascript"

Browse Popular Code Answers by Language