join() The join() method creates and returns a new string by concatenating all of the elements in an array (or an array-like object), separated by commas or a specified separator string. If the array has only one item, then that item will be returned without using the separator.
To merge objects into a new one that has all properties of the merged objects, you have two options: Use a spread operator ( ... ) Use the Object. assign() method.
I've got an array of objects with a few properties, such as 'value' and 'label'.
array.join(' ')
of course gives me "[object] [object]", but instead I need to get a string of the 'value' properties of all objects, separated by a space.
What is the shortest way to do this, and is this possible without writing a for loop?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With