by Sai gowtham

How use map method in JavaScript

In es6, we got most useful array methods in JavaScript one of them is Array.map() method in this tutorial we will learn about how to use the map method.

The map method takes the callback function as an argument and runs on each element present in the array, at final it returns the new array with the updated values.

map method doesn’t mutate/change the original array.

Example:

function doubleNumbers(arr){
    return arr.map((num) => num*2 );
}

console.log(doubleNumbers([1,2,3,4,5])) // [2,4,6,8,10]

The callback function inside the map method takes three parameters currentvalue , index , array.

function convertIntegers(arr){

    return arr.map((num)=> Number(num) );

}


console.log(convertIntegers(["1","2","3","4"]))

//output   [1, 2, 3, 4]

Css Tutorials & Demos

How rotate an image continuously in CSS

In this demo, we are going to learn about how to rotate an image continuously using the css animations.

How to create a Instagram login Page

In this demo, i will show you how to create a instagram login page using html and css.

How to create a pulse animation in CSS

In this demo, i will show you how to create a pulse animation using css.

Creating a snowfall animation using css and JavaScript

In this demo, i will show you how to create a snow fall animation using css and JavaScript.

Top Udemy Courses

JavaScript - The Complete Guide 2021 (Beginner + Advanced)
JavaScript - The Complete Guide 2021 (Beginner + Advanced)
64,026 students enrolled
52 hours of video content
View Course
React - The Complete Guide (incl Hooks, React Router, Redux)
React - The Complete Guide (incl Hooks, React Router, Redux)
284,472 students enrolled
40 hours of video content
View Course
Vue - The Complete Guide (w/ Router, Vuex, Composition API)
Vue - The Complete Guide (w/ Router, Vuex, Composition API)
152,857 students enrolled
48.5 hours of video content
View Course