Open In App

Ember.js EmberArray mapBy() Method

Last Updated : 23 Sep, 2022
Improve
Improve
Like Article
Like
Save
Share
Report

Ember.js is an open-source JavaScript framework used for developing large client-side web applications which is based on Model-View-Controller (MVC) architecture. Ember.js is one of the most widely used front-end application frameworks. It is made to speed up development and increase productivity. Currently, it is utilized by a large number of websites, including Square, Discourse, Groupon, Linked In, Live Nation, Twitch, and Chipotle.

The mapBy() method is used to get the value of the named property on all items in the enumeration.

Syntax:

mapBy(key);

Parameters:

  • key: It is the name of the property whose value we want.

Return Value: A mapped array.

Steps to Install and Run Ember.js:

To run the following examples you will need to have an ember project with you. To create one, you will need to install ember-cli first. Write the below code in the terminal:

npm install ember-cli

Now you can create the project by typing in the following piece of code:

ember new <project-name> --lang en

To start the server, type:

ember serve

Example 1: Type the following code to generate the route for this example:

ember generate route mapBy1
app/routes/mapBy1.js

 
app/controllers/mapBy1.js

 
app/templates/mapBy1.hbs

 

Output: Visit localhost:4200/mapBy1 to view the output

Ember.js EmberArray mapBy method

Example 2: Type the following code to generate the route for this example:

ember generate route mapBy2
app/routes/mapBy2.js

 
app/controllers/mapBy2.js

 
app/templates/mapBy2.hbs

 

Output: Visit localhost:4200/mapBy2 to view the output

Ember.js EmberArray mapBy method

Reference: https://api.emberjs.com/ember/2.14/classes/Ember.Array/methods/mapBy?anchor=mapBy


Like Article
Suggest improvement
Next
Share your thoughts in the comments

Similar Reads

Ember.js Ember.NativeArray mapBy() Method
Ember.js MutableArray mapBy() Method
Ember.js ArrayProxy mapBy() Method
Ember.js EmberArray uniqBy() Method
Ember.js EmberArray getEach() Method
Ember.js EmberArray findBy() Method
Ember.js EmberArray slice() Method
Ember.js EmberArray toArray() Method
Ember.js EmberArray compact() Method
Ember.js EmberArray any() Method