JavaScript Maps are super underrated

preview_player
Показать описание
JavaScript Maps are super underrated.

Keys of a map can be anything - including an object!

Here I'm using the new groupBy proposed API to group array items →
Рекомендации по теме
Комментарии
Автор

Okay this method is actually easier.

I needed to do something like this and I had to use Proxy to reference other objects and a small algorithm to find where the key exists in different set of objects. I don't know if Maps can solve this issue but I'll definitely try it out

thelazycoder
Автор

I have been using Maps in my code for quite some time. I think devs underestimate this collection often because of JS functional concepts and object literals.

forestlaw
Автор

Quick question: how would access work if the keys are objects? One thing that I find useful about maps is O(1) access with a specific key. How would that work with objects? Would it still be O(1) and it's indexed by reference, or we basically have to go for O(n) and find manually by value comparison?

foxmaestro
Автор

I think the main reason I dont use maps more often is its unability to be json stringified/parsed. I know there are workarounds but until it becomes as easy as json.stringify(map) I find it just adds overhead

amgadtawfik
Автор

This exists in Kotlin, cool to see it coming to Javascript

superhumandose
Автор

Why do I get different results than you, what's going on?

xgqfrms