Тёмный
No video :(

Convert ARRAY to OBJECT in javascript - JavaScript Interview Questions  

Coder Dost
Подписаться 80 тыс.
Просмотров 201 тыс.
50% 1

How to convert Array to Object in JavaScript? Find out here in 1 minute
🤯 Crash Courses (Single Video)
Git/Github Crash Course : bit.ly/3JSA5VT
TypeScript Crash Course : bit.ly/372dZSh
Angular Crash Course : bit.ly/3DoGJR1
Vue JS Crash Course : bit.ly/3uDujRl
Python Crash Course : bit.ly/3Dod7U2
React Router Crash Course : bit.ly/36YfO2i
🧑‍🏫 Full Course Playlists
HTML : bit.ly/36IMq0h
CSS : bit.ly/3LpRQw6
JavaScript : bit.ly/3u049tf
BootStrap : bit.ly/3NA9nDJ
ES 6 : bit.ly/3DvYCh6
DOM Playlist : bit.ly/35nMKB7
ReactJS (Redux & Hooks) : bit.ly/3iMethN
React with TypeScript : bit.ly/3fQjXtF
React Hooks: bit.ly/3Vmh7wV
Redux: bit.ly/3yAIIkl
NodeJS/ExpressJS : bit.ly/35nN6Yt
MongoDB / Mongoose : bit.ly/3qPj0EO
💻 Projects Playlists
MERN Stack Complete Ecommerce : bit.ly/3ymSs0E
Web Design HTML+CSS - Home Page : bit.ly/35nZiIB
Web Design BootStrap - E-Commerce Site : bit.ly/3iPhaz7
React/Redux/Firebase - Todo-App : bit.ly/3DnekL8
🕹 Mini Projects (Single Video)
React - Tic Tac Toe (Redux / Hooks) : bit.ly/3uzLEuy
React - Game of Flag Quiz (Hooks) : bit.ly/3LpTC0e
React - Google Translate Clone (Hooks) : bit.ly/3Lo9xvZ
React - Chat App using Firebase (Hooks) : bit.ly/3wLgymj
Visit our site: coderdost.com
🔴 Full Courses List : coderdost.com/...
🔴 Full Projects List : coderdost.com/...
💾 Source Codes at : github.com/cod...

Опубликовано:

 

5 сен 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 74   
@coderdost
@coderdost Год назад
Course of JavaScript : bit.ly/3u049tf Course of Modern JS. (ES6) : bit.ly/3DvYCh6 React JS MasterClass (10 Hour) : ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-6l8RWV8D-Yo.html NODE+ EXPRESS+ MONGO MasterClass (12 Hour) : ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-ChVE-JbtYbM.html React Interviews : bit.ly/3QAjAln JavaScript Shorts: bit.ly/3XhHRQ1 React Shorts : bit.ly/3VfIrMi
@crazyviralteam5796
@crazyviralteam5796 8 месяцев назад
❤😊
@veerlamuralikrishna4774
@veerlamuralikrishna4774 7 месяцев назад
simple way let obj =[1.2,3] console.log({...obj})
@jayatighosh4626
@jayatighosh4626 6 месяцев назад
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 = []; Object.keys(obj).map(key=>newArr.push(key)); console.log(newArr)
@nitesh0581
@nitesh0581 Месяц назад
2 ways: const newArr=Object.assign([],obj); console.log(newArr); const newArr=Object.values(obj).map((val)=>val); console.log(newArr); more simpler one : const newArr=Object.values(obj); console.log(newArr);
@Spider-Man_67
@Spider-Man_67 Год назад
Easy way // Convert an array into an object. const names = ['Rahul','Krityveer','Anish','Gopal','Parveen']; const obj = {...names } console.log(obj);
@n_fan329
@n_fan329 Год назад
still not 100% correct, in this case keys are not identical to the values
@aliarslanansari
@aliarslanansari 2 месяца назад
@@n_fan329 no one want keys identical to values
@funterban6536
@funterban6536 4 месяца назад
most of the one channel in youtube which uploaded the best question for interviews in 1 minute
@adarshkhatri993
@adarshkhatri993 Год назад
Object.keys(), Object.values(), Object.entries() to convert into array??
@semicolon6499
@semicolon6499 10 месяцев назад
Ha
@faizalkhan2437
@faizalkhan2437 6 месяцев назад
Object.entries(obj) or if you wanna iterate the value only so you can go with object. Values(obj).
@ZigZag-ry3zm
@ZigZag-ry3zm Год назад
Which extension do you use to get that return info while changing something in the function?
@coderdost
@coderdost Год назад
Quokka js
@Yaduvanshi-nw3yr
@Yaduvanshi-nw3yr 6 месяцев назад
Solution --------> Object.keys(Obj).map(i =>obj[i])
@channel6k
@channel6k Год назад
let arr=["a","b","c"]; let obj={}; for( let i=0 ;i
@coderdost
@coderdost Год назад
Yes that will also work
@ayushkamar7100
@ayushkamar7100 Год назад
Ye sir enteries se bi to ho sakta hain ❤❤
@vishal10471
@vishal10471 Год назад
Please add some more video in this playlist, please
@iron_man____
@iron_man____ 10 месяцев назад
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' }
@davidbaraiya2649
@davidbaraiya2649 Год назад
Which extention for inline result ?
@coderdost
@coderdost Год назад
Quokka js
@AmritpalSingh-sw3bl
@AmritpalSingh-sw3bl 10 месяцев назад
Using for each loop we can handle it easily
@vaibhav_gamingg
@vaibhav_gamingg Год назад
Bhaii ap kese kr rhe ho sb Muje JS smj he nhi atti thi and u make it very simple for me thanku.
@killerdroid99
@killerdroid99 11 месяцев назад
you can use a record for these conversions
@abhishekstorycreator
@abhishekstorycreator Год назад
Object.values()
@IIndianCoder
@IIndianCoder 26 дней назад
Object.values(obj) To convert obj into array ✅
@pankajsharma-rf1ov
@pankajsharma-rf1ov Год назад
My question is why it is taking only the last one in case of string means ({...a,it:it}) o/p {it:"a"} But why ({...a,[it]:it}) gives right answer I am still not clarified.
@coderdost
@coderdost Год назад
When you put a square bracket on key of an object. The variable is evaluated and then the result is assigned as key string. This feature is used a lot in forms. {[e.target.name]:e.target.value} this kind of syntax you will see in lot of frontend forms..
@pankajsharma-rf1ov
@pankajsharma-rf1ov Год назад
@coderdost after over a time I realised that when the data is entered in the object like {it:"a"} and in further iteration data is entered with different value but with the same key that's why our last key value is modified or replaced with new one bcz key is the same.
@coderdost
@coderdost Год назад
👍🏻 yes
@diveshpatidar5159
@diveshpatidar5159 9 месяцев назад
Let newArr = [...Object.values(obj)]; //['a', 'b', 'c']
@vaxff1945
@vaxff1945 Год назад
logic was simple but code should be readabe i was scared after this short later i understood
@rahulkhandelwal1967
@rahulkhandelwal1967 Год назад
Nice share 🙌
@akshaysalunkhe3226
@akshaysalunkhe3226 Год назад
Object.assign({}, object name)
@pritamkeshri8389
@pritamkeshri8389 Год назад
Awesome
@syedjaidahmed1728
@syedjaidahmed1728 Год назад
Love from Bangladesh
@jamshedahmad6069
@jamshedahmad6069 Год назад
Using the Object.assign() method to convert an array to an object ,e.g. const obj = Object.assign({}, arr). Using the spread syntax (...) to convert an array to an object, e.g. const obj = {...arr}. Using the Array.forEach() method to iterate over all items and add them as a key-value pair to an object. Using the Object.fromEntries() method to convert an array of key-value pairs to an object, e.g. const obj = Object.fromEntries(arr).
@coderdost
@coderdost Год назад
great info
@user-tg1wd2xb6j
@user-tg1wd2xb6j Год назад
Aap kaun sa code editor use karte ho. yeah console ki command bhi code mein hi Dikhai ja raha hai ya aap kaise kar rahe ho. Aap ko subscribe Kar Diya Hai Ab lajmi batana.
@coderdost
@coderdost Год назад
VScode with Quokka JS extension
@improve777
@improve777 Год назад
awesome, Software ka name batao na!
@coderdost
@coderdost Год назад
quokka js extension
@murtazashahidofficial3790
@murtazashahidofficial3790 Год назад
Which code editor is this? Kindly share
@coderdost
@coderdost Год назад
VScode but with custom theme (setting json modified)
@murtazashahidofficial3790
@murtazashahidofficial3790 Год назад
@@coderdost sir please ye kese karty hen aap bata sakty hen please mai buhat try karha hun mere vs code mai JS nhi run hora mai dhundh dhundh ke thak gya hun
@hirenahir76200
@hirenahir76200 5 месяцев назад
Bro ye answers side me kese aa rahe ge?
@akash.web_dev
@akash.web_dev Год назад
const arr=['a','b','c'] let obj = Object.assign({},arr) console.log(obj); let array= Object.entries(obj) console.log(array.flat()); array to object and object to array ye ek good approch hai ya nahi
@ajaypanchal1106
@ajaypanchal1106 Год назад
const arr = [1, 23, 4, 56, 7]; // convert it into object const out = arr.reduce((num, crt, i, ar) => { return { ...num, [crt]: crt }; }, {}); console.log(out); const rev = Object.values(out).reduce((prev, current, index, arr) => { return [...prev, current]; }, []); console.log(rev);
@unknowneditor2799
@unknowneditor2799 Год назад
My question is that can program understand who is subject and object in array sentence ?
@coderdost
@coderdost Год назад
program must use some library to understand that language, other wise by simple logic its not possible.
@anshulsingh6825
@anshulsingh6825 Год назад
Object. Keys(array_name)
@zaynff2m860
@zaynff2m860 8 месяцев назад
Sir theem kon si hi
@nakulnagariya7736
@nakulnagariya7736 Год назад
Object.entriesFrom
@prabhattambe4047
@prabhattambe4047 Год назад
Array.from()
@scriptDoodle
@scriptDoodle Год назад
Which extension gives results beside code like yours?
@coderdost
@coderdost Год назад
Quokka JS
@real_vincenzo
@real_vincenzo Год назад
Kitne time Lage aapko javascript Sikhne mein ? Aapki tarah kaise sikhu ?
@coderdost
@coderdost Год назад
I am using from 2010
@n_fan329
@n_fan329 Год назад
let tab=[] for (let val in obj){ tab.push(obj[val]) } console.log(tab2)
@tigerguru2850
@tigerguru2850 Год назад
Ye konsa theme hai??
@coderdost
@coderdost Год назад
Dark theme + Customized settings.json of VSCode
@tigerguru2850
@tigerguru2850 Год назад
@@coderdost ispe ek shorts bnao.
@vishal10471
@vishal10471 Год назад
Arr.reverse
@user-mv7gi5fz5g
@user-mv7gi5fz5g Месяц назад
Sir ab time aa gya koi project laane kaa
@syedjaidahmed1728
@syedjaidahmed1728 Год назад
big fan
@sashirkl
@sashirkl Год назад
Boss kuch samajh mein nahin aya . And funny part is i know programming. Mujhe kuch knowledge hoke agar samajh nahin aya dusre ko kya aega
@coderdost
@coderdost Год назад
these are just tricky question ppl ask sometime in interviews. They are not normal in everyday work of JS developer. But good for practice.
@hishamkhan4913
@hishamkhan4913 Год назад
Bro .. coding se upar he javascript... Js padho sahi se... He explained perfectly...
@naveensanai5378
@naveensanai5378 Год назад
video ko reverse karo ho jayega 😂😂
@coderdost
@coderdost Год назад
😂
@webmobi2773
@webmobi2773 Год назад
var emptyObj= { } are.forEach((val)=> { emptyObj[val] = val; } console.log(emptyObj); 🎉🎉🎉🎉🎉🎉🎉🎉🎉🎉
@rahultripathi6935
@rahultripathi6935 Год назад
Awesome
Далее
Hoisting in JavaScript #javascript #reactjs #shorts
1:00
3d printed demon core vs real
00:24
Просмотров 6 млн
8 Must Know JavaScript Array Methods
10:05
Просмотров 1 млн
5 JavaScript Concepts You HAVE TO KNOW
9:38
Просмотров 1,4 млн
JavaScript LIVE Coding Interview Round (Mock)
18:55
Просмотров 39 тыс.
3d printed demon core vs real
00:24
Просмотров 6 млн