I am trying to return an array that contain of one of property. So there is an array of objects like
[{x: 5, y: 607, width: 782, height: 602, line_width: 3, …},
{x: 10, y: 602, width: 772, height: 592, line_width: 3, …},
{x: 0, y: 400, size: 18, text: 'This cer..}, ..]
Some object has section: 'TextInstruction' property defined and some do not.
I am trying to return an array that is only containing section with no duplicate and no undefined.
So return ['TextInstruction', 'RectangleInstruction', ...]
No [undefined, 'TextInstruction', 'TextInstruction', ...]
Can anyone help me with JavaScript to get this using reduce() function?
reduce? Seems like you want to filter the objects that do not have asectionkey. Also, the intended result is unclear; it looks like what you want is an array of the unique values of thesectionkey, which you could do easily with the answers to From an array of objects, extract value of a property as array and Get all non-unique values (i.e.: duplicate/more than one occurrence) in an array