JavaScript Tip: Retrieving a Property from an Array of Objects

preview_player
Показать описание
At times you may receive an array of objects when retrieving data from a site. Yet you may only need one property from each object. Let's look at how we can take that array of objects and retrieve a single property into another array.

Would you like to help keep this channel going?

Tutorials referred to in this video:

For more resources on JavaScript:

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

Very concise yet informative explanations well done

aaron
Автор

Bro thank you great video! I love how simple you make learning sound

n.dclothing
Автор

Excelente video! Thank you so much. I was banging my head against my desk before I found your video.

anishita
Автор

This video was a live saver,
I tried lopping the array, then looping object within the array at each iteration, but i could not solve the problem

thbo-kxbq
Автор

Two things here:



1. higher order functions like filter, map, reduce, etc. return an array by themselves, so you're replacing the "titles" array you created earlier.
Hence just declaring a variable "titles" without assigning any value works perfectly fine.



2. ...AAAND this is why "let" is the correct variable keyword here.
At the same time, you can manipulate (fill/empty) an array (or an object for that matter) that you declared using "const" beforehand, all permissible and perfectly fine as long as you don't change its data type.



However, maybe you did some of this for educational purposes (I'm sure you're very well aware of the above-mentioned).

christian-schubert
Автор

Thank you! I was able to figure out how to find the data and display it on my app after some tinkering. Have a great day! Word.

TheLegendOfMrDGaming
Автор

I don't understand why the array "titles" updated inside a .then() can be accessed outside the .then() in the console...

jizhang
Автор

Idk if youll answer this but why couldnt you just access it by doing `console.log(json.titles)`

cheesepotato
Автор

Could you make a video about how to create your own email opt-out link using javascript?

jrseven
Автор

Maybe it is a silly question, but why not using .append method for the array instead of .map? Something like: titles.append(obj => obj.title)

soniferous
Автор

That's great thank you very much! Now my second problwem is Once I retrieved the data nedeed, I want to put back that data that I modified in a new property name, For example a new property called TitlesInUppercase. How can I ad d TitlesinUppercase inside that array of object? Thank so much

vincenzoriwu
Автор

hi..do you have any teaching where i can learn about DTO and DAO? thanks for your videos

thaboramohlale