Video yükleniyor...

Video Yüklenemedi

Ana Sayfaya Dön

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 into a Map or an Object →

240,399 görüntüleme • 3 yıl önce •via X (Twitter)

11 Yorum

Nick Taylor profil fotoğrafı
Nick Taylor3 yıl önce

WeakMaps ftw as well!

Wes Bos profil fotoğrafı
Wes Bos3 yıl önce

Nothing better than something that cleans up

Paulo Reis profil fotoğrafı
Paulo Reis3 yıl önce

I've been using the JavaScript Maps a lot, thanks for the teachings 💯

Wes Bos profil fotoğrafı
Wes Bos3 yıl önce

big fan!

zayenz 🐀 profil fotoğrafı
zayenz 🐀3 yıl önce

Maps are great, but I really miss structural equality for the keys when they are objects, as that is so much more useful. Especially if the key is computed at lookup.

Wes Bos profil fotoğrafı
Wes Bos3 yıl önce

I agree, I wonder if we will ever get that in JS

Web-Dev-Codi profil fotoğrafı
Web-Dev-Codi3 yıl önce

YT comment: You should use a for loop for performance. Wes: I'm iterating over 3 things brotha. 🤣 This was hilarious

vovô ermitão profil fotoğrafı
vovô ermitão3 yıl önce

except that it lacks a hashing function hook

Wes Bos profil fotoğrafı
Wes Bos3 yıl önce

@crudspecialist What would we use that for? Not snark, curious!

Rocky profil fotoğrafı
Rocky3 yıl önce

@wesbos where can we find this video or podcasts ? Really interested in it

Wes Bos profil fotoğrafı
Wes Bos3 yıl önce

This is it - I made it for twitter

Benzer Videolar

Here's a copy/paste prompt recipe and vid showing exactly how to ask an LLM for an interactive map with satellite/map layers + a georeferencer that lets you see how old maps correspond with modern geography. Today the computer can’t make good print maps (that's your hill to climb ) but it can, with five bucks and twenty minutes, make good interactive maps. No software/GIS knowledge necessary, you just need a few nouns and an LLM. Scroll to the bottom for the repo/live map if you want those. I'm using Claude Code as an extension in VS Code but you can use the Claude CLI, Cursor, whatever. 1) Let's grab an old cadastral map and see who owned big tracts of a city; I found this an 1854 map of Niagara Falls, NY I found in the Library of Congress: , grabbed the .jp2, saved as a jpg from photoshop. 2) Let's ask Claude Code for a map. You can see exactly what I did in the video but my prompt, sans simple "hey it's busted" debugging, is written out in the following paragraphs. I explain the map-specific nouns in brackets. You can likely dump this whole thing in your LLM window and it'll work; I'd try plan mode + skip permissions. THE PROMPT Make an interactive map with MapLibre GL JS [maplibre is a javascript mapping library, a FOSS version of Mapbox GL JS. This lets us display tiled map data and arbitrary images on the map] Add basemap toggles with Esri satellite, Carto Positron, and OSM [these map layers require no API keys for light usage; Carto Positron is a nice road map layer and OSM is ugly but comprehensive] Add a globe/mercator projection toggle [I think the globe looks better at low zooms] Add a layer panel on the left with visibility checkboxes and delete buttons. Add a search box on the map that flies to results, with deletable pin markers [Makes this easy to get to your area of interest] Include an interactive local georeferencer: drop a JPG, pick ground control points on a zoomable/pannable image viewer, place them on the map, watch it warp with a progress bar centered on the map. [The georeferencer uses math ("affine transform"??) to match points on the old map to points on the new map; generally you click road intersections on the old map, match them on the new map, repeat a dozen times and everything aligns] The georeferenced map overlay defaults to 25% opacity with a slider above the control point list. [I want it easy to see the underlying modern geography] Add Export/import control point buttons [this saves the control points as a JSON so you can save and reimport your work] Add a button to export the warped image as a GeoTIFF with a .prj [In case you want to add the georeferenced image to a real GIS program like QGIS] Look up all relevant docs before starting [Claude sometimes uses outdated stuff] Split everything into separate HTML/CSS/JS files [Claude tends to pile everything in index.html, which is hard to read] Use Optima font, base color #FEFAF6 [I just like this style] Let me test with a local server [it serves it on a simple server so you can nav your host to localhost:8000 and try it out] Log all errors [so you don't have to play telephone with the LLM describing what's busted] 3) Once your LLM finishes, test it out in your browser; if it doesn't work, ask the LLM to check logs. Repeat 'til functional. 4) After this works on your computer, you can show it to everyone by hosting it on GitHub: prompt with "write a README explaining what everything does, add it to a new GitHub repo, deploy using GitHub pages, gimme the live URL" Here's what Claude made for me, try it yourself: • Upload the JPG in the repo, which is linked below • "Add GCP" • Click somewhere recognizable on the old map, like the tip of an island or a road intersection • Click the matching point on the new map • Repeat til you have least 3x points • Hit "georeference" • You'll see the old map atop the new map; if you want a better fit, delete bad points or add a dozen new ones, hit georeference again, repeat Repo: Is this map robust? Human-maintainable? Elegant? Performant? Secure? No, but *your* personal web map need not be. It just needs to work for *your* narrow use case, because it’s *your* map.

Evan Applegate

15,772 görüntüleme • 5 ay önce