First step is to extract name. You can use map
.
elements.map(x=>x.name)
Second step is to join it to one string using join
const result = elements.map(x=>x.name).join(' - ');
More Related Contents:
- `export const` vs. `export default` in ES6
- Javascript – arrow functions this in event handler?
- How does this object method definition work without the “function” keyword?
- What is the temporal dead zone?
- Are ES6 classes just syntactic sugar for the prototypal pattern in Javascript?
- ES6 Array destructuring weirdness
- Get functions (methods) of a class [duplicate]
- ES6 Iterate over class methods
- Can’t require() default export value in Babel 6.x
- Access to ES6 array element index inside for-of loop
- ES6 Destructuring and Module imports
- Using spread operator multiple times in javascript?
- forEach is not a function error with JavaScript array
- Why do I have to .bind(this) for methods defined in React component class, but not in regular ES6 class
- ES6: Is it dangerous to delete elements from Set/Map during Set/Map iteration?
- where is create-react-app webpack config and files?
- Extending Error in Javascript with ES6 syntax & Babel
- Shallow-clone a Map or Set
- Why is the response object from JavaScript fetch API a promise?
- Importing multiple files in react
- check if function is a generator
- JavaScript object destructuring and aliasing
- Alternative version for Object.values()
- `if __name__ == ‘__main__’` equivalent in javascript es6 modules
- In the `import` syntax of ES6, how is a module evaluated exactly?
- Curly brackets (braces) in Node.js ‘require’ statement
- ES6 promise execution order for returned values
- How can I differentiate between an arrow function, class and a normal function?
- How to call native es6 template string replacement from tag function?
- ECMA6 generators: yield promise