Hello Friends đź‘‹,

Welcome To Infinitbility! ❤️

Today, we are going to learn how we can add an array in the object, in javascript, and other javascript frameworks.

All below tutorials work on javascript, React, React Native, Vue, Node, Deno, typescript, and all javascript frameworks.

For adding an element in the object we have many options but in these tutorials, we will use object.key = value this syntax because of object-store everything in key-value pair.

/*
 * 👋 Welcome to Infinitbility 🚀
 */

let array = ['1', '2', '3'];
let object = {};

console.log('array >', array);
console.log('object >', object);

// add array in object
object.array = array;
console.log('object >', object);

output

Add array in object, Example

Thanks for reading…