How to get unique object properties in JavaScript

preview_player
Показать описание
In this tutorial, we'll look at how to get unique object properties in JavaScript.

Imagine the scenario where you have a group of objects, stored in separate variables and you want to get a list of the unique properties from all of the objects.

In the video, we'll look at a couple of different ways of doing this.

The first is to use a JavaScript reduce function. In order to use this, we need to put the objects in to an array and initialise the reduce function as an empty array.

The second method is to use a JavaScript map function in a similar way. However with this approach, we'll need to make sure we call the JavaScript flat function on the end of the call to map to ensure we don't get nested arrays.

#JavaScript #JavaScriptHowtos #Objects Channel Handle @codebubb
Рекомендации по теме
Комментарии
Автор

Thanks, and I have question how can I get keys if it array objects? I have one array objects [{}, {}, {}], in you example I get keys 0, 1, 2 and if I use ...Object.values(item) I get all object nested

sergiokuguk
Автор

Hi, I just watched your random name generator video and I want to make a function that changes the text to what you want.
So I did it but the font isn't the same, can you help?

VLTNO
welcome to shbcf.ru