Map vs Object in JavaScript

preview_player
Показать описание
Want to learn some practical differences with how you interact with Maps and Objects in JavaScript?

---------- Course

---------- Connect

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

A note about the swapObj method you used, it will actually be done in O(N^2) complexity due to reduce+spread are iterating twice, you can do it better by either using Object.fromEntries or Object.assign to iterate in O(N)

omri
Автор

Leigh Halliday, I actually love your channel and appreciate these small clips you put out. You always introduce me to something new as a growing developer! Thanks, ALOT!

KayB
Автор

Great video. If you're looking for a video topic or just generally taking suggestions, I would love to see you cover TypeScript generics and partials.

xAndy
Автор

Thank you for posting knowledge! For me, this channel and all the work you put in it helps me out. I started on the path of web development alone and I learned a great deal from your React videos. I really like the way you explain things, makes them easy to understand.

TomaNeagu
Автор

absolutely amazing and to the point comparison!

DebopriyoBasu
Автор

Thanks! I love tutorials when they go right to the point ❤

GonzaloherreraTuc
Автор

I love the way you organize the tutorial, pretty awesome!

alii
Автор

very interesting. I've been programming JS and TS for almost 6 years, never used Map, although seems to be cool

yoyo-
Автор

Great explanation and examples. We should really be using Maps more

tonybrown
Автор

i watched several videos on map object, I stopped here because you hit all the points. thank you

KennethChambers-vngf
Автор

how can I favorite methods like in 9:44?

yanbatista
Автор

Another great video. Thanks, I've been stuck on using an arrow function return with reduce. I didn't know you had to spread the acc.

introvertsgo
Автор

What is the practicality of swapping the keys and values?
This video shows some of the differences between the two, but does not show why you would use one over the other.
OBJ over MAP
-If dealing with data from/to an API
--Due to JSON format is normally required
-if dealing with data that is always going to have the same keys
MAP over OBJ
-If you will delete and add new keys
--This is due to a slight speed up

PS: It is relatively simple to convert one to the other, but still it is still a thing

deathone
Автор

Nice video, thanks! I’d like to use Map more, just need to start.
Small note: you say in object the order isn’t guaranteed. Actually, it’s guaranteed, but in ‘some special way’ :) integer properties are sorted, others appear in creation order.

vadim
Автор

I am struggling with DBs. Maybe a good idea to compare Supabase vs. Prisma? ease of use, speed, auth integration, dev speed...

endernator
Автор

Hey.. just found out your video and love it! Do you have other videos that talks about the performance between Map and Plain Object? Thanks!

seepoot
Автор

Not related to the topic but how are you getting a full height vertical output window in your vscode setup in the right panel? Is this a package?

AmitErandole
Автор

Interesting how Python does it the other way round, with the expressions that look like JavaScript “object” ones actually constructing dictionaries, while general Python objects have custom construction facilities (or you could use canned ones like dataclasses).

Basically, JavaScript tried to mash dictionaries and general objects together, and then discovered this was not such a good idea, so it had to add a separate dictionary (Map) type anyway. Python kept them separate, and ended up with a cleaner and simpler design overall.

lawrencedoliveiro
Автор

Very good and useful but I wonder if you could mention how to use stringify with maps?

always-ask-why
Автор

I love the simplicity of Objects, or maybe I am biased cause I have been working with objects a lot. You mentioned there are performance benefits to using maps?

shrestha