Ads Top

What is map in javascript?

Map example in javascript:
Map() method needs a callback function or object. It's return value in the array. It works with value if you don't have value then it does not work. Also, this method maintains value of the original array.  This example created a new array Or you can send dynamic value. Then I have used map with this new array, here I have passed a function getMap(), then the result will be shown as below:
<h3><b>Your Result:</b></h3>

                <script>
                var numericArray = ["abc""Hello"124];
                var newArrValue = numericArray.map(getMap)
                
                function getMap(num) {
                  return num + ': ';
                }
                
                document.write(newArrValue);
                </script>
Result will be:

No comments:

Copyright Reserved to Anything Learn. Powered by Blogger.