{"id":5512,"date":"2023-03-19T10:19:02","date_gmt":"2023-03-19T14:19:02","guid":{"rendered":"https:\/\/www.cloudsurph.com\/?p=5512"},"modified":"2023-03-19T10:22:09","modified_gmt":"2023-03-19T14:22:09","slug":"transform-arrays-with-map-method","status":"publish","type":"post","link":"https:\/\/www.cloudsurph.com\/transform-arrays-with-map-method\/","title":{"rendered":"Transform Arrays with Map() Method"},"content":{"rendered":"<h1><strong>The map() Method in JavaScript<\/strong><\/h1>\n<p>The map() method in JavaScript allows you to apply a function to each element of an array, creating a new array with the transformed values.<\/p>\n<h5><em><strong>If you want then buy a good, reliable, secure web\u00a0<a href=\"https:\/\/www.cloudsurph.com\/windows-vps-hosting\/\">hosting<\/a>\u00a0service \u00a0from here:\u00a0<a href=\"https:\/\/hosting.cloudsurph.com\/\">click here<\/a><\/strong><\/em><\/h5>\n<p>In this article, we try to discuss some JavaScript Questions like How to convert an array to a map, What the map () array method does, How do you use the map() function, Transform Arrays with Map() Method, How to Transform Arrays using Map() Method, Why Use the map() Method, The map() Method in JavaScript, The Array.map() Method with Callback Functions, JavaScript Array map() Method: Transforming Array Elements, JavaScript map() Method: How to Transform Arrays, How to Transform Arrays using JavaScript Map() Method.<\/p>\n<h3><strong>JavaScript Map() Method: How To Transform Arrays<\/strong><\/h3>\n<p>In JavaScript, we can use\u00a0<strong><a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/JavaScript\/Reference\/Global_Objects\/Array\/map\">Array.map()<\/a><\/strong>\u00a0method for <strong>Taking<\/strong>\u00a0an existing array, <strong>Applying<\/strong>\u00a0an operation for each element of the array, and <strong>Getting<\/strong>\u00a0a new array with modified elements.<\/p>\n<p>For instance, given an array of numbers, we can do a new array of the numbers squared given code below<\/p>\n<pre class=\"prettyprint\">\r\nconst numbers = [1, 2, 3, 4, 5]\r\nconst squared = numbers.map(num =&gt; num * num)\r\nconsole.log(squared)\r\n<\/pre>\n<p><strong>Output:<\/strong><\/p>\n<pre class=\"prettyprint\">\r\n[1, 4, 9, 16, 25]\r\n<\/pre>\n<h5><em><strong>If you want then buy a good, reliable, secure web\u00a0<a href=\"https:\/\/www.cloudsurph.com\/windows-vps-hosting\/\">hosting<\/a>\u00a0service \u00a0from here:\u00a0<a href=\"https:\/\/hosting.cloudsurph.com\/\">click here<\/a><\/strong><\/em><\/h5>\n<h3>Why Use the map() Method?<\/h3>\n<p>In JavaScript, we can use the<strong>\u00a0map()<\/strong>\u00a0method to make our code shorter and more summarized.<\/p>\n<p>The\u00a0<strong>map()<\/strong>\u00a0method lets you replace some lengthy loops with good-looking shorthand statements.<\/p>\n<h3>Previous JavaScript Articles<\/h3>\n<ul>\n<li><a href=\"https:\/\/www.cloudsurph.com\/javascript-variables\/\" aria-current=\"page\">JavaScript Variables<\/a><\/li>\n<li><a href=\"https:\/\/www.cloudsurph.com\/javascript-operators\/\">JavaScript Operators<\/a><\/li>\n<li><a href=\"https:\/\/www.cloudsurph.com\/creating-an-object-in-javascript\/\">Creating an Object in JavaScript<\/a><\/li>\n<li><a href=\"https:\/\/www.cloudsurph.com\/what-is-asynchronous-javascript\/\">Introduction to Asynchronous JavaScript<\/a><\/li>\n<li><a href=\"https:\/\/www.cloudsurph.com\/what-is-control-flow-in-javascript\/\">Control Flow in JavaScript<\/a><\/li>\n<li><a href=\"https:\/\/www.cloudsurph.com\/how-to-use-regex-in-javascript-function\/\">What is JavaScript Regex?<\/a><\/li>\n<li><a href=\"https:\/\/www.cloudsurph.com\/javascript-events-example\/\" aria-current=\"page\">JavaScript Events Example<\/a><\/li>\n<li><a href=\"https:\/\/www.cloudsurph.com\/how-to-create-a-preloader-in-javascript\/\" aria-current=\"page\">How to create a preloader in JavaScript?<\/a><\/li>\n<li><a href=\"https:\/\/www.cloudsurph.com\/foreach-method-in-javascript\/\" aria-current=\"page\">forEach method in JavaScript<\/a><\/li>\n<li><a href=\"https:\/\/www.cloudsurph.com\/sorting-arrays-in-javascript\/\" aria-current=\"page\">Sorting Arrays in JavaScript<\/a><\/li>\n<li><a href=\"https:\/\/www.cloudsurph.com\/what-is-linear-search-in-javascript\/\" aria-current=\"page\">Linear Search in JavaScript<\/a><\/li>\n<li><a href=\"https:\/\/www.cloudsurph.com\/pagination-in-vanilla-javascript\/\" aria-current=\"page\">Pagination in Vanilla JavaScript<\/a><\/li>\n<\/ul>\n<h3>The map() Method in JavaScript<\/h3>\n<p>In JavaScript, the\u00a0<strong>Array.map()<\/strong>\u00a0method calls a function for each element in an array and the result is a new array with new transformed values.<\/p>\n<p>So, we can start by looking at the syntax of the\u00a0<strong>map()<\/strong>\u00a0method.<\/p>\n<h3>The Array.map() Method with Callback Functions<\/h3>\n<p>In this case, the most basic way to use the\u00a0<strong>map()<\/strong>\u00a0method is by passing it a callback function.<\/p>\n<p>For instance, we can do square an array of numbers.<\/p>\n<pre class=\"prettyprint\">\r\nconst numbers = [1, 2, 3, 4, 5]\r\nfunction square(number) {\r\nreturn number * number\r\n}\r\nconst squared = numbers.map(square)\r\nconsole.log(squared)\r\n<\/pre>\n<p><strong>Output:<\/strong><\/p>\n<pre class=\"prettyprint\">\r\n[1, 4, 9, 16, 25]\r\n<\/pre>\n<h3>The Array.map() Method with Inline Callback Functions<\/h3>\n<p>In this method, the word \u201cinline\u201d refers to a function used\u00a0<em>in the line<\/em>\u00a0of code where it is implemented and we called the\u00a0<strong>map()<\/strong>\u00a0method with a callback function that was defined separately.<\/p>\n<h5><em><strong>You can purchase your\u00a0<a href=\"https:\/\/hosting.cloudsurph.com\/\">hosting from Cloudsurph.com<\/a>,\u00a0<a href=\"https:\/\/hosting.cloudsurph.com\/\">Cloudsurph hosting<\/a>\u00a0is a reliable hosting option for business and personal projects. We offer insight and help on system configuration issues and code errors or bugs<\/strong>.<\/em><\/h5>\n<p>However, we can also define the callback inline when calling the\u00a0<strong>map()<\/strong>\u00a0method and this means you implement the function without a name right in the\u00a0<strong>map()<\/strong>\u00a0method call.<\/p>\n<p>For example, we can do square an array of numbers:<\/p>\n<pre class=\"prettyprint\">\r\nconst numbers = [1, 2, 3, 4, 5]\r\nconst squared = numbers.map(function(number) {\r\nreturn number * number\r\n})\r\nconsole.log(squared)\r\n<\/pre>\n<p><strong>Output:<\/strong><\/p>\n<pre class=\"prettyprint\">\r\n[1, 4, 9, 16, 25]\r\n<\/pre>\n<h3>The Array.map() Method with Arrow Functions<\/h3>\n<p>An\u00a0<a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/JavaScript\/Reference\/Functions\/Arrow_functions\">arrow function<\/a>\u00a0is a shorthand alternative for a traditional function expression and we cannot always use an arrow function.<\/p>\n<p>To keep it short, we did not go to list the arrow function limitations here. Instead, we can check them\u00a0<a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/JavaScript\/Reference\/Functions\/Arrow_functions\">here<\/a>.<\/p>\n<p>So, arrow functions can be used with the following below syntaxes:<\/p>\n<pre class=\"prettyprint\">\r\nconst numbers = [1, 2, 3, 4, 5]\r\nconst squared = numbers.map(num =&gt; num * num)\r\nconsole.log(squared)\r\n<\/pre>\n<p><strong>Output:<\/strong><\/p>\n<pre class=\"prettyprint\">\r\n[1, 4, 9, 16, 25]\r\n<\/pre>\n<h3>Example Use Cases for the map() Method<\/h3>\n<p>Last but not least, let\u2019s take a look at some examples of how to use the map() method.<\/p>\n<h3>Call a Function for Each Element in an Array for map()<\/h3>\n<p>You can use the map() method to transform one array into another by calling a function for each element in the array.<\/p>\n<p>For instance, we can create a new array with the strings in the upper case.<\/p>\n<pre class=\"prettyprint\">\r\nconst names = [\"Alice\", \"Bob\", \"Charlie\"]\r\nconst capsNames = names.map(name =&gt; name.toUpperCase())\r\nconsole.log(capsNames)\r\n<\/pre>\n<p><strong>Output:<\/strong><\/p>\n<pre class=\"prettyprint\">\r\n[\"ALICE\", \"BOB\", \"CHARLIE\"]\r\n<\/pre>\n<h3>Reformat Array Objects<\/h3>\n<p>The\u00a0<strong>map()<\/strong>\u00a0method can be used when working with arrays of objects as well.<\/p>\n<pre class=\"prettyprint\">\r\nconst users = [\r\n{ name: 'Bob', hobby: 'Jogging' },\r\n{ name: 'Charlie', hobby: 'Gym' },\r\n{ name: 'Alice', hobby: 'Golf' }\r\n]\r\nconst capsData = users.map(user =&gt; {\r\nconst userData = {}\r\nuserData.name = user.name.toUpperCase()\r\nuserData.hobby = user.hobby.toUpperCase()\r\nreturn userData\r\n})\r\nconsole.log(capsData)\r\n<\/pre>\n<p><strong>Output:<\/strong><\/p>\n<pre class=\"prettyprint\">\r\n[{\r\nhobby: \"JOGGING\", name: \"BOB\"\r\n}, {\r\nhobby: \"GYM\", name: \"CHARLIE\"\r\n}, {\r\nhobby: \"GOLF\", name: \"ALICE\"\r\n}]\r\n<\/pre>\n<h3>Convert String to an Array of Characters<\/h3>\n<p>The\u00a0<strong>map()<\/strong>\u00a0method is known to belong to the\u00a0<strong>Array<\/strong>\u00a0data type.<\/p>\n<p>However, we can extract this method from the\u00a0<strong>Array<\/strong>, also use it on a string.<\/p>\n<p>To do this, use the\u00a0<strong>.call()<\/strong>\u00a0method.<\/p>\n<p>The\u00a0<strong>.call()<\/strong>\u00a0method lets you use the context of one object for another. In this case, you can use the\u00a0<strong>map()<\/strong>\u00a0method that belongs to an\u00a0<strong>Array<\/strong>\u00a0on a\u00a0<strong>String<\/strong>.<\/p>\n<pre class=\"prettyprint\">\r\nconst name = \"Sam\"\r\nconst arr = Array.prototype.map.call(name, letter =&gt; letter.toUpperCase())\r\nconsole.log(arr)\r\n<\/pre>\n<p><strong>Output:<\/strong><\/p>\n<pre class=\"prettyprint\">\r\n[\"S\", \"A\", \"M\"]\r\n<\/pre>\n<h3>Conclusion<\/h3>\n<p>Today you learned how to use the\u00a0<strong>map()<\/strong> method in JavaScript and the\u00a0<strong>map()<\/strong>\u00a0method we can be used to transform one array into another.<\/p>\n<p>In each of these examples, the map() method transforms the elements of an array in a specific way to create a new array with the transformed values.<\/p>\n<h5><em><strong>If you want then buy a good, reliable, secure web\u00a0<a href=\"https:\/\/www.cloudsurph.com\/windows-vps-hosting\/\">hosting<\/a>\u00a0service \u00a0from here:\u00a0<a href=\"https:\/\/hosting.cloudsurph.com\/\">click here<\/a><\/strong><\/em><\/h5>\n<p>That\u2019s it. If you enjoyed reading this article and have more questions please reach out to our\u00a0<a href=\"https:\/\/hosting.cloudsurph.com\/submitticket.php?step=2&amp;deptid=1\">support team<\/a>\u00a0via live chat or\u00a0<a href=\"mailto:support@cloudsurph.com\">email<\/a>\u00a0and we would be glad to help you. we provide server\u00a0<a href=\"https:\/\/hosting.cloudsurph.com\/\">hosting<\/a>\u00a0for all types of need and we can even get your\u00a0<a href=\"https:\/\/hosting.cloudsurph.com\/\">server<\/a>\u00a0up and running with the service of your choice.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>The map() Method in JavaScript The map() method in JavaScript allows you to apply a function to each element of an array, creating a new array with the transformed values. If you want then buy a good, reliable, secure web\u00a0hosting\u00a0service \u00a0from here:\u00a0click here In this article, we try to discuss some JavaScript Questions like How [&hellip;]<\/p>\n","protected":false},"author":8,"featured_media":5513,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_et_pb_use_builder":"","_et_pb_old_content":"","_et_gb_content_width":"","footnotes":""},"categories":[157,25,162,159,1,31],"tags":[54,47,105,103,48,113],"class_list":["post-5512","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-centos-7","category-web-hosting-virtualization","category-javascript","category-linux-server","category-virtual-private-servers","category-web-hosting","tag-best-vps-hosting-server-maryland","tag-cheap-cloud-servers","tag-cheap-storage-server-hosting","tag-cheapest-vps","tag-dedicated-server-hosting-in-washington-d-c","tag-speed-test-vps"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.3 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>How to Transform Arrays using JavaScript Map() Method<\/title>\n<meta name=\"description\" content=\"Why Use the map() Method, The map() Method in JavaScript, JavaScript map() Method: How to Transform Arrays, Transform Arrays with Map()\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.cloudsurph.com\/transform-arrays-with-map-method\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to Transform Arrays using JavaScript Map() Method\" \/>\n<meta property=\"og:description\" content=\"Why Use the map() Method, The map() Method in JavaScript, JavaScript map() Method: How to Transform Arrays, Transform Arrays with Map()\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.cloudsurph.com\/transform-arrays-with-map-method\/\" \/>\n<meta property=\"og:site_name\" content=\"Cloudsurph Web Hosting Washington D.C.\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/CloudSurph\/\" \/>\n<meta property=\"article:published_time\" content=\"2023-03-19T14:19:02+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2023-03-19T14:22:09+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.cloudsurph.com\/wp-content\/uploads\/2023\/03\/How-to-Transform-Arrays-using-JavaScript-Map-Method.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"1264\" \/>\n\t<meta property=\"og:image:height\" content=\"760\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Rony\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@cloudsurph\" \/>\n<meta name=\"twitter:site\" content=\"@Cloud_Surph\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Rony\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"5 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.cloudsurph.com\\\/transform-arrays-with-map-method\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.cloudsurph.com\\\/transform-arrays-with-map-method\\\/\"},\"author\":{\"name\":\"Rony\",\"@id\":\"https:\\\/\\\/www.cloudsurph.com\\\/#\\\/schema\\\/person\\\/ac9b4dd136d96e50d5f29c560191e7ed\"},\"headline\":\"Transform Arrays with Map() Method\",\"datePublished\":\"2023-03-19T14:19:02+00:00\",\"dateModified\":\"2023-03-19T14:22:09+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.cloudsurph.com\\\/transform-arrays-with-map-method\\\/\"},\"wordCount\":841,\"publisher\":{\"@id\":\"https:\\\/\\\/www.cloudsurph.com\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/www.cloudsurph.com\\\/transform-arrays-with-map-method\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.cloudsurph.com\\\/wp-content\\\/uploads\\\/2023\\\/03\\\/How-to-Transform-Arrays-using-JavaScript-Map-Method.jpg\",\"keywords\":[\"Best VPS hosting server Maryland\",\"Cheap Cloud Servers\",\"Cheap Storage Server Hosting\",\"Cheapest VPS\",\"Dedicated Server Hosting in Washington D.C\",\"Speed test VPS\"],\"articleSection\":[\"CentOS 7\",\"Cloud Hosting\",\"JavaScript\",\"Linux Server\",\"VPS Servers\",\"Web Hosting\"],\"inLanguage\":\"en-US\"},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.cloudsurph.com\\\/transform-arrays-with-map-method\\\/\",\"url\":\"https:\\\/\\\/www.cloudsurph.com\\\/transform-arrays-with-map-method\\\/\",\"name\":\"How to Transform Arrays using JavaScript Map() Method\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.cloudsurph.com\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.cloudsurph.com\\\/transform-arrays-with-map-method\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.cloudsurph.com\\\/transform-arrays-with-map-method\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.cloudsurph.com\\\/wp-content\\\/uploads\\\/2023\\\/03\\\/How-to-Transform-Arrays-using-JavaScript-Map-Method.jpg\",\"datePublished\":\"2023-03-19T14:19:02+00:00\",\"dateModified\":\"2023-03-19T14:22:09+00:00\",\"description\":\"Why Use the map() Method, The map() Method in JavaScript, JavaScript map() Method: How to Transform Arrays, Transform Arrays with Map()\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.cloudsurph.com\\\/transform-arrays-with-map-method\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.cloudsurph.com\\\/transform-arrays-with-map-method\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.cloudsurph.com\\\/transform-arrays-with-map-method\\\/#primaryimage\",\"url\":\"https:\\\/\\\/www.cloudsurph.com\\\/wp-content\\\/uploads\\\/2023\\\/03\\\/How-to-Transform-Arrays-using-JavaScript-Map-Method.jpg\",\"contentUrl\":\"https:\\\/\\\/www.cloudsurph.com\\\/wp-content\\\/uploads\\\/2023\\\/03\\\/How-to-Transform-Arrays-using-JavaScript-Map-Method.jpg\",\"width\":1264,\"height\":760,\"caption\":\"How to Transform Arrays using JavaScript Map() Method\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.cloudsurph.com\\\/transform-arrays-with-map-method\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.cloudsurph.com\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Transform Arrays with Map() Method\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.cloudsurph.com\\\/#website\",\"url\":\"https:\\\/\\\/www.cloudsurph.com\\\/\",\"name\":\"Cloudsurph Web Hosting Washington D.C.\",\"description\":\"Dedicated Server Hosting\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.cloudsurph.com\\\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.cloudsurph.com\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/www.cloudsurph.com\\\/#organization\",\"name\":\"CloudSurph Technology Solutions\",\"url\":\"https:\\\/\\\/www.cloudsurph.com\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.cloudsurph.com\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/www.cloudsurph.com\\\/wp-content\\\/uploads\\\/2016\\\/04\\\/cloudsurph-logo.png\",\"contentUrl\":\"https:\\\/\\\/www.cloudsurph.com\\\/wp-content\\\/uploads\\\/2016\\\/04\\\/cloudsurph-logo.png\",\"width\":2348,\"height\":1692,\"caption\":\"CloudSurph Technology Solutions\"},\"image\":{\"@id\":\"https:\\\/\\\/www.cloudsurph.com\\\/#\\\/schema\\\/logo\\\/image\\\/\"},\"sameAs\":[\"https:\\\/\\\/www.facebook.com\\\/CloudSurph\\\/\",\"https:\\\/\\\/x.com\\\/Cloud_Surph\"]},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.cloudsurph.com\\\/#\\\/schema\\\/person\\\/ac9b4dd136d96e50d5f29c560191e7ed\",\"name\":\"Rony\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/40163fe1eb49d5eddd81954e8ad5122633e141df15b0733d07fbe4a156688ba5?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/40163fe1eb49d5eddd81954e8ad5122633e141df15b0733d07fbe4a156688ba5?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/40163fe1eb49d5eddd81954e8ad5122633e141df15b0733d07fbe4a156688ba5?s=96&d=mm&r=g\",\"caption\":\"Rony\"},\"sameAs\":[\"https:\\\/\\\/x.com\\\/cloudsurph\"],\"url\":\"https:\\\/\\\/www.cloudsurph.com\\\/author\\\/ron\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"How to Transform Arrays using JavaScript Map() Method","description":"Why Use the map() Method, The map() Method in JavaScript, JavaScript map() Method: How to Transform Arrays, Transform Arrays with Map()","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.cloudsurph.com\/transform-arrays-with-map-method\/","og_locale":"en_US","og_type":"article","og_title":"How to Transform Arrays using JavaScript Map() Method","og_description":"Why Use the map() Method, The map() Method in JavaScript, JavaScript map() Method: How to Transform Arrays, Transform Arrays with Map()","og_url":"https:\/\/www.cloudsurph.com\/transform-arrays-with-map-method\/","og_site_name":"Cloudsurph Web Hosting Washington D.C.","article_publisher":"https:\/\/www.facebook.com\/CloudSurph\/","article_published_time":"2023-03-19T14:19:02+00:00","article_modified_time":"2023-03-19T14:22:09+00:00","og_image":[{"width":1264,"height":760,"url":"https:\/\/www.cloudsurph.com\/wp-content\/uploads\/2023\/03\/How-to-Transform-Arrays-using-JavaScript-Map-Method.jpg","type":"image\/jpeg"}],"author":"Rony","twitter_card":"summary_large_image","twitter_creator":"@cloudsurph","twitter_site":"@Cloud_Surph","twitter_misc":{"Written by":"Rony","Est. reading time":"5 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.cloudsurph.com\/transform-arrays-with-map-method\/#article","isPartOf":{"@id":"https:\/\/www.cloudsurph.com\/transform-arrays-with-map-method\/"},"author":{"name":"Rony","@id":"https:\/\/www.cloudsurph.com\/#\/schema\/person\/ac9b4dd136d96e50d5f29c560191e7ed"},"headline":"Transform Arrays with Map() Method","datePublished":"2023-03-19T14:19:02+00:00","dateModified":"2023-03-19T14:22:09+00:00","mainEntityOfPage":{"@id":"https:\/\/www.cloudsurph.com\/transform-arrays-with-map-method\/"},"wordCount":841,"publisher":{"@id":"https:\/\/www.cloudsurph.com\/#organization"},"image":{"@id":"https:\/\/www.cloudsurph.com\/transform-arrays-with-map-method\/#primaryimage"},"thumbnailUrl":"https:\/\/www.cloudsurph.com\/wp-content\/uploads\/2023\/03\/How-to-Transform-Arrays-using-JavaScript-Map-Method.jpg","keywords":["Best VPS hosting server Maryland","Cheap Cloud Servers","Cheap Storage Server Hosting","Cheapest VPS","Dedicated Server Hosting in Washington D.C","Speed test VPS"],"articleSection":["CentOS 7","Cloud Hosting","JavaScript","Linux Server","VPS Servers","Web Hosting"],"inLanguage":"en-US"},{"@type":"WebPage","@id":"https:\/\/www.cloudsurph.com\/transform-arrays-with-map-method\/","url":"https:\/\/www.cloudsurph.com\/transform-arrays-with-map-method\/","name":"How to Transform Arrays using JavaScript Map() Method","isPartOf":{"@id":"https:\/\/www.cloudsurph.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.cloudsurph.com\/transform-arrays-with-map-method\/#primaryimage"},"image":{"@id":"https:\/\/www.cloudsurph.com\/transform-arrays-with-map-method\/#primaryimage"},"thumbnailUrl":"https:\/\/www.cloudsurph.com\/wp-content\/uploads\/2023\/03\/How-to-Transform-Arrays-using-JavaScript-Map-Method.jpg","datePublished":"2023-03-19T14:19:02+00:00","dateModified":"2023-03-19T14:22:09+00:00","description":"Why Use the map() Method, The map() Method in JavaScript, JavaScript map() Method: How to Transform Arrays, Transform Arrays with Map()","breadcrumb":{"@id":"https:\/\/www.cloudsurph.com\/transform-arrays-with-map-method\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.cloudsurph.com\/transform-arrays-with-map-method\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.cloudsurph.com\/transform-arrays-with-map-method\/#primaryimage","url":"https:\/\/www.cloudsurph.com\/wp-content\/uploads\/2023\/03\/How-to-Transform-Arrays-using-JavaScript-Map-Method.jpg","contentUrl":"https:\/\/www.cloudsurph.com\/wp-content\/uploads\/2023\/03\/How-to-Transform-Arrays-using-JavaScript-Map-Method.jpg","width":1264,"height":760,"caption":"How to Transform Arrays using JavaScript Map() Method"},{"@type":"BreadcrumbList","@id":"https:\/\/www.cloudsurph.com\/transform-arrays-with-map-method\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.cloudsurph.com\/"},{"@type":"ListItem","position":2,"name":"Transform Arrays with Map() Method"}]},{"@type":"WebSite","@id":"https:\/\/www.cloudsurph.com\/#website","url":"https:\/\/www.cloudsurph.com\/","name":"Cloudsurph Web Hosting Washington D.C.","description":"Dedicated Server Hosting","publisher":{"@id":"https:\/\/www.cloudsurph.com\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.cloudsurph.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.cloudsurph.com\/#organization","name":"CloudSurph Technology Solutions","url":"https:\/\/www.cloudsurph.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.cloudsurph.com\/#\/schema\/logo\/image\/","url":"https:\/\/www.cloudsurph.com\/wp-content\/uploads\/2016\/04\/cloudsurph-logo.png","contentUrl":"https:\/\/www.cloudsurph.com\/wp-content\/uploads\/2016\/04\/cloudsurph-logo.png","width":2348,"height":1692,"caption":"CloudSurph Technology Solutions"},"image":{"@id":"https:\/\/www.cloudsurph.com\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/CloudSurph\/","https:\/\/x.com\/Cloud_Surph"]},{"@type":"Person","@id":"https:\/\/www.cloudsurph.com\/#\/schema\/person\/ac9b4dd136d96e50d5f29c560191e7ed","name":"Rony","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/40163fe1eb49d5eddd81954e8ad5122633e141df15b0733d07fbe4a156688ba5?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/40163fe1eb49d5eddd81954e8ad5122633e141df15b0733d07fbe4a156688ba5?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/40163fe1eb49d5eddd81954e8ad5122633e141df15b0733d07fbe4a156688ba5?s=96&d=mm&r=g","caption":"Rony"},"sameAs":["https:\/\/x.com\/cloudsurph"],"url":"https:\/\/www.cloudsurph.com\/author\/ron\/"}]}},"_links":{"self":[{"href":"https:\/\/www.cloudsurph.com\/wp-json\/wp\/v2\/posts\/5512","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.cloudsurph.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.cloudsurph.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.cloudsurph.com\/wp-json\/wp\/v2\/users\/8"}],"replies":[{"embeddable":true,"href":"https:\/\/www.cloudsurph.com\/wp-json\/wp\/v2\/comments?post=5512"}],"version-history":[{"count":2,"href":"https:\/\/www.cloudsurph.com\/wp-json\/wp\/v2\/posts\/5512\/revisions"}],"predecessor-version":[{"id":5515,"href":"https:\/\/www.cloudsurph.com\/wp-json\/wp\/v2\/posts\/5512\/revisions\/5515"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.cloudsurph.com\/wp-json\/wp\/v2\/media\/5513"}],"wp:attachment":[{"href":"https:\/\/www.cloudsurph.com\/wp-json\/wp\/v2\/media?parent=5512"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.cloudsurph.com\/wp-json\/wp\/v2\/categories?post=5512"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.cloudsurph.com\/wp-json\/wp\/v2\/tags?post=5512"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}