How to Use Array Map using Node Js?
Jan 08, 2022 . Admin

Hello Friends,
This article will give you example of node js array map example. I explained simply about node js convert array to map. This tutorial will give you simple example of node js create map from array. This is a short guide on use node js array map function in nodejs
In this post, you'll learn how to use array map function in node js. i will show you javascript array map() method. we will use array map function given below.
Here i will give you many example of how to use array map function in node js.
Example 1 :
Run following command to create node app.
mkdir my-app cd my-app npm initStep 2 : Create server.js file
server.js
const temp = [1, 5, 3, 12]; const temp2 = temp.map(x => x * 2); console.log(temp2);
now you can simply run by following command:
node server.jsOutput :
[ 2, 10, 6, 24 ]
Example 2 :
Step 1 : Create Node AppRun following command to create node app.
mkdir my-app cd my-app npm initStep 2 : Create server.js file
server.js
let temp = [1, 4, 6] let dblNum = temp.map(function(num) { return num * 2 }) console.log(dblNum);
now you can simply run by following command:
node server.jsOutput :
[ 2, 8, 12 ]
It will help you...