Convert ARRAY to OBJECT in javascript - JavaScript Interview Questions #reactjs #javascript

preview_player
Показать описание
How to convert Array to Object in JavaScript? Find out here in 1 minute

🤯 Crash Courses (Single Video)

🧑‍🏫 Full Course Playlists

💻 Projects Playlists

🕹 Mini Projects (Single Video)

Рекомендации по теме
Комментарии
Автор




JavaScript Shorts:

React Shorts :

coderdost
Автор

simple way
let obj =[1.2, 3]
console.log({...obj})

veerlamuralikrishna
Автор

let arr = ['Sun', 'Moon', 'Star']
// Convert array to object
let obj = {};
let contertToObj = arr.forEach(i=>obj[i] = i);
console.log(obj)

// Convert object to array
let newArr = [];

console.log(newArr)

jayatighosh
Автор

2 ways:

const newArr=Object.assign([], obj);
console.log(newArr);

const
console.log(newArr);

more simpler one :
const newArr=Object.values(obj);
console.log(newArr);

nitesh
Автор

Easy way
// Convert an array into an object.
const names = ['Rahul', 'Krityveer', 'Anish', 'Gopal', 'Parveen'];

const obj = {...names }

console.log(obj);

Spider-Man_
Автор

most of the one channel in youtube which uploaded the best question for interviews in 1 minute

funterban
Автор

Solution

Object.keys(Obj).map(i =>obj[i])

Yaduvanshi-nwyr
Автор

Object.keys(), Object.values(), Object.entries() to convert into array??

adarshkhatri
Автор

Which extension do you use to get that return info while changing something in the function?

ZigZag-ryzm
Автор

Object.entries(obj) or if you wanna iterate the value only so you can go with object. Values(obj).

faizalkhan
Автор

let arr=["a", "b", "c"];
let obj={};

for( let i=0 ;i<arr.length ;i++){
let name=arr[i];
if(obj[name]===undefined){
obj[name]=arr[i]
}

}
console.log(obj) i can do like this ???

channelk
Автор

Please add some more video in this playlist, please

vishal
Автор

Ye sir enteries se bi to ho sakta hain ❤❤

ayushkamar
Автор

Object.values(obj)
To convert obj into array ✅

IIndianCoder
Автор

let tab=[]
for (let val in obj){
tab.push(obj[val])
}
console.log(tab2)

n_fan
Автор

let arr = ['a', 'b', 'c']

let obj = arr.reduce((a, it, i)=>{
a[it] = it
return a
}, {})
console.log(obj)
//{ a: 'a', b: 'b', c: 'c' }

iron_man____
Автор

Bhaii ap kese kr rhe ho sb
Muje JS smj he nhi atti thi and u make it very simple for me thanku.

vaibhav_gamingg
Автор

Using for each loop we can handle it easily

AmritpalSingh-swbl
Автор

awesome,
Software ka name batao na!

improve
Автор

you can use a record for these conversions

killerdroid