{"id":11868,"date":"2020-10-22T04:12:00","date_gmt":"2020-10-22T11:12:00","guid":{"rendered":"https:\/\/careerkarma.com\/blog\/?p=11868"},"modified":"2023-12-01T04:03:20","modified_gmt":"2023-12-01T12:03:20","slug":"javascript-filter-reduce","status":"publish","type":"post","link":"https:\/\/careerkarma.com\/blog\/javascript-filter-reduce\/","title":{"rendered":"JavaScript Filter: A Step-By-Step Guide"},"content":{"rendered":"\n<p><em>The JavaScript() filter method creates an array of elements from an existing array. The filter() method accepts a callback function as an argument. This function evaluates whether an element should be added to the new list from the existing one.<\/em><\/p>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<p>If you are new to <a href=\"https:\/\/careerkarma.com\/blog\/what-is-javascript-used-for\/\">JavaScript<\/a>, you may not have heard of the <em>filter()<\/em> and <em>reduce()<\/em>Javascript functions. These functions can be useful when you are working with a list of objects, also known as an <em>array<\/em>.<\/p>\n\n\n\n<p>If you have ever wanted to get only certain values from an array, you can use the JavaScript&nbsp;<em>filter()<\/em>&nbsp;function. In this tutorial, we will discuss, with reference to examples, how to use the filter() function.<\/p>\n\n\n\n<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_82_2 counter-hierarchy ez-toc-counter ez-toc-custom ez-toc-container-direction\">\n<label for=\"ez-toc-cssicon-toggle-item-69e874ef97905\" class=\"ez-toc-cssicon-toggle-label\"><span class=\"\"><span class=\"eztoc-hide\" style=\"display:none;\">Toggle<\/span><span class=\"ez-toc-icon-toggle-span\"><svg style=\"fill: #000000;color:#000000\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"list-377408\" width=\"20px\" height=\"20px\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M6 6H4v2h2V6zm14 0H8v2h12V6zM4 11h2v2H4v-2zm16 0H8v2h12v-2zM4 16h2v2H4v-2zm16 0H8v2h12v-2z\" fill=\"currentColor\"><\/path><\/svg><svg style=\"fill: #000000;color:#000000\" class=\"arrow-unsorted-368013\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"10px\" height=\"10px\" viewBox=\"0 0 24 24\" version=\"1.2\" baseProfile=\"tiny\"><path d=\"M18.2 9.3l-6.2-6.3-6.2 6.3c-.2.2-.3.4-.3.7s.1.5.3.7c.2.2.4.3.7.3h11c.3 0 .5-.1.7-.3.2-.2.3-.5.3-.7s-.1-.5-.3-.7zM5.8 14.7l6.2 6.3 6.2-6.3c.2-.2.3-.5.3-.7s-.1-.5-.3-.7c-.2-.2-.4-.3-.7-.3h-11c-.3 0-.5.1-.7.3-.2.2-.3.5-.3.7s.1.5.3.7z\"\/><\/svg><\/span><\/span><\/label><input type=\"checkbox\"  id=\"ez-toc-cssicon-toggle-item-69e874ef97905\"  aria-label=\"Toggle\" \/><nav><ul class='ez-toc-list ez-toc-list-level-1 ' ><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/careerkarma.com\/blog\/javascript-filter-reduce\/#array-refresher\" >Array Refresher<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/careerkarma.com\/blog\/javascript-filter-reduce\/#javascript-filter-array\" >JavaScript Filter Array<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/careerkarma.com\/blog\/javascript-filter-reduce\/#filter-javascript-examples\" >Filter JavaScript Examples<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/careerkarma.com\/blog\/javascript-filter-reduce\/#conclusion\" >Conclusion<\/a><\/li><\/ul><\/nav><\/div>\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"array-refresher\"><\/span>Array Refresher<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>An <a href=\"https:\/\/careerkarma.com\/blog\/javascript-array\/\">JavaScript array<\/a> stores zero or more items. Items can be numbers, other arrays, strings, or use another data type. They use numbered indices starting from \u201c0\u201d to access specific items.<\/p>\n\n\n\n<p>Arrays let you store multiple values in the same variable. This can help you write better and cleaner because you don\u2019t need to write multiple variables to store your values.<\/p>\n\n\n\n<p>Here is an example of an array in JavaScript:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>let names = [&quot;Alex&quot;, &quot;Bill&quot;, &quot;Connor&quot;, &quot;Daniel&quot;, &quot;Edna&quot;];<\/pre><\/div>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"javascript-filter-array\"><\/span>JavaScript Filter Array<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>The JavaScript array filter() method creates a new array based on the contents of an existing array. The filter() method evaluates a callback function on each item in an existing array. Any item that meets the condition in the callback function is added to a new list.<\/p>\n\n\n\n<p>Using the filter method, we are able to retrieve values that meet certain criteria and add them to a new array.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Filter Array JavaScript Syntax<\/h3>\n\n\n\n<p>The filter method uses the following syntax:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>var newArr = oldArr.filter(function(item) {\n\treturn yourCondition;\n});<\/pre><\/div>\n\n\n\n<p>This code defines an array called &#8220;newArr&#8221; based on the contents of the &#8220;oldArr&#8221; array. Our callback function returns a value to the new array if a condition is met. Example conditions include:<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>item &gt; 5<\/li><li>item == &#8220;Jessie&#8221;<\/li><li>item &lt; 3<\/li><\/ul>\n\n\n\n<p>You could use JavaScript comparison operators to build your conditions. Or, you could use an if statement. Using an if statement lets you control which one of multiple values is added to a new list.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"filter-javascript-examples\"><\/span>Filter JavaScript Examples<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">Filter a List of Numbers<\/h3>\n\n\n\n<p>Let&#8217;s start with a simple example. We have a list of purchases from a coffee shop. We want to create a new list which displays purchases over $10.<\/p>\n\n\n\n<p>Our list of purchases looks like this:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>var purchases = [2.50, 2.70, 10.50, 12.30, 9.60, 2.30, 3.40];<\/pre><\/div>\n\n\n\n<p>We can use the filter() method to retrieve the purchases worth more than $10:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>var big_purchases = purchases.filter(function(purchase) {\n\treturn purchase &gt; 10;\n});<\/pre><\/div>\n\n\n\n<p>Our program checks whether a purchase was worth more than $10.A purchase is added to our <em>big_purchases<\/em> list if it is worth more than $10. Otherwise, the purchase is left out.<\/p>\n\n\n\n<p>The value of the big_purchases <a href=\"https:\/\/careerkarma.com\/blog\/javascript-variables\/\">JavaScript variable<\/a> is:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>[10.5, 12.3]<\/pre><\/div>\n\n\n\n<p>The filter() method returns all the elements that pass the test we have defined. This test is &#8220;item &gt; 10&#8221;. If we wanted to access every purchase, we could refer back to our original &#8220;purchases&#8221; list. Our filter() method returns an array of values greater than $10.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Filter an Array of Objects<\/h3>\n\n\n\n<p>We have an array that contains the names of everyone in a school:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>var students = [\n\t{\n\t\tid: 1,\n\t\tname: &quot;Alex&quot;,\n\t\tclass: &quot;First Grade&quot;,\n\t\tage: 5\n\t},\n{\n\t\tid: 2,\n\t\tname: &quot;Bill&quot;,\n\t\tclass: &quot;First Grade&quot;,\n\t\tage: 5\n\t},\n{\n\t\tid: 3,\n\t\tname: &quot;Connor&quot;,\n\t\tclass: &quot;Second Grade&quot;,\n\t\tage: 6\n\t}\n];<\/pre><\/div>\n\n\n\n<p>What if we only want to retrieve the students who are in first grade? <em>Filter()<\/em> makes it easy to perform this operation. Let\u2019s write a function that will return all first-graders from the \u201cstudents\u201d array:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>var firstGradeStudents = students.filter(function (student) {\n\treturn student.class === \u201cFirst Grade\u201d;\n});<\/pre><\/div>\n\n\n\n<p><em>Filter()<\/em> takes in one parameter. This is a function that determines what operation you run on your data. <\/p>\n\n\n\n<p>The <em>filter()<\/em> function goes through every object in the \u201cstudents\u201d array. filter() returns students whose class is equal to \u201cFirst Grade.\u201d The \u201c===\u201d operator means equality. \n\n<\/p>\n\n\n\n<p>The filter function will create a new array with these new values, accessible through the \u201cfirstGradeStudents\u201d variable.<\/p>\n\n\n\n<iframe loading=\"lazy\" src=\"https:\/\/repl.it\/@careerkarma\/A-Guide-to-Filter-and-Reduce-in-JavaScript?lite=true\" width=\"100%\" height=\"400px\" frameborder=\"0\"><\/iframe>\n<br>\n<br>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"conclusion\"><\/span>Conclusion<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>You can use the filter() array method to create a new array from the contents of an existing array. The clue is in the name with the filter() method. filter() <em>filters<\/em> out elements from an existing array.<\/p>\n\n\n\n<p>And that\u2019s it! Now you can use <em>reduce()<\/em> in JavaScript with even more confidence. To learn more about how to code in JavaScript, read our article on the <a href=\"https:\/\/careerkarma.com\/blog\/tutorial-for-javascript-beginners\/\">best tutorials for JavaScript beginners<\/a>.\n<\/p>\n","protected":false},"excerpt":{"rendered":"The JavaScript() filter method creates an array of elements from an existing array. The filter() method accepts a callback function as an argument. This function evaluates whether an element should be added to the new list from the existing one. If you are new to JavaScript, you may not have heard of the filter() and&hellip;","protected":false},"author":240,"featured_media":12331,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[11933],"tags":[12687],"class_list":{"0":"post-11868","1":"post","2":"type-post","3":"status-publish","4":"format-standard","5":"has-post-thumbnail","7":"category-javascript","8":"tag-tutorial"},"acf":{"post_sub_title":"","sprint_id":"","query_class":"JavaScript","school_sft":"","parent_sft":"","school_privacy_policy":"","has_review":null,"is_sponser_post":"","is_guest_post":""},"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v27.4 (Yoast SEO v27.4) - https:\/\/yoast.com\/product\/yoast-seo-premium-wordpress\/ -->\n<title>JavaScript Filter: A Step-By-Step Guide | Career Karma<\/title>\n<meta name=\"description\" content=\"In JavaScript, it\u2019s common to want to filter out objects or run a calculation on an array. Learn more in this Career Karma article.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/careerkarma.com\/blog\/javascript-filter-reduce\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"JavaScript Filter: A Step-By-Step Guide\" \/>\n<meta property=\"og:description\" content=\"In JavaScript, it\u2019s common to want to filter out objects or run a calculation on an array. Learn more in this Career Karma article.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/careerkarma.com\/blog\/javascript-filter-reduce\/\" \/>\n<meta property=\"og:site_name\" content=\"Career Karma\" \/>\n<meta property=\"article:publisher\" content=\"http:\/\/facebook.com\/careerkarmaapp\" \/>\n<meta property=\"article:published_time\" content=\"2020-10-22T11:12:00+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2023-12-01T12:03:20+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/02\/javascript-filter-and-reduce.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"1200\" \/>\n\t<meta property=\"og:image:height\" content=\"675\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"James Gallagher\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@career_karma\" \/>\n<meta name=\"twitter:site\" content=\"@career_karma\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"James Gallagher\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"4 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/javascript-filter-reduce\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/javascript-filter-reduce\\\/\"},\"author\":{\"name\":\"James Gallagher\",\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/#\\\/schema\\\/person\\\/e79364792443fbff794a144c67ec8e94\"},\"headline\":\"JavaScript Filter: A Step-By-Step Guide\",\"datePublished\":\"2020-10-22T11:12:00+00:00\",\"dateModified\":\"2023-12-01T12:03:20+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/javascript-filter-reduce\\\/\"},\"wordCount\":675,\"commentCount\":0,\"image\":{\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/javascript-filter-reduce\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/wp-content\\\/uploads\\\/2020\\\/02\\\/javascript-filter-and-reduce.jpg\",\"keywords\":[\"tutorial\"],\"articleSection\":[\"JavaScript\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/careerkarma.com\\\/blog\\\/javascript-filter-reduce\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/javascript-filter-reduce\\\/\",\"url\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/javascript-filter-reduce\\\/\",\"name\":\"JavaScript Filter: A Step-By-Step Guide | Career Karma\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/javascript-filter-reduce\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/javascript-filter-reduce\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/wp-content\\\/uploads\\\/2020\\\/02\\\/javascript-filter-and-reduce.jpg\",\"datePublished\":\"2020-10-22T11:12:00+00:00\",\"dateModified\":\"2023-12-01T12:03:20+00:00\",\"author\":{\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/#\\\/schema\\\/person\\\/e79364792443fbff794a144c67ec8e94\"},\"description\":\"In JavaScript, it\u2019s common to want to filter out objects or run a calculation on an array. Learn more in this Career Karma article.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/javascript-filter-reduce\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/careerkarma.com\\\/blog\\\/javascript-filter-reduce\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/javascript-filter-reduce\\\/#primaryimage\",\"url\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/wp-content\\\/uploads\\\/2020\\\/02\\\/javascript-filter-and-reduce.jpg\",\"contentUrl\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/wp-content\\\/uploads\\\/2020\\\/02\\\/javascript-filter-and-reduce.jpg\",\"width\":1200,\"height\":675,\"caption\":\"JavaScript Filter and Reduce\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/javascript-filter-reduce\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Blog\",\"item\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"JavaScript\",\"item\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/javascript\\\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"JavaScript Filter: A Step-By-Step Guide\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/\",\"name\":\"Career Karma\",\"description\":\"Latest Coding Bootcamp News &amp; Career Hacks from Industry Insiders\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/#\\\/schema\\\/person\\\/e79364792443fbff794a144c67ec8e94\",\"name\":\"James Gallagher\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/wp-content\\\/uploads\\\/2020\\\/01\\\/james-gallagher-150x150.jpg\",\"url\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/wp-content\\\/uploads\\\/2020\\\/01\\\/james-gallagher-150x150.jpg\",\"contentUrl\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/wp-content\\\/uploads\\\/2020\\\/01\\\/james-gallagher-150x150.jpg\",\"caption\":\"James Gallagher\"},\"description\":\"James Gallagher is a self-taught programmer and the technical content manager at Career Karma. He has experience in range of programming languages and extensive expertise in Python, HTML, CSS, and JavaScript. James has written hundreds of programming tutorials, and he frequently contributes to publications like Codecademy, Treehouse, Repl.it, Afrotech, and others.\",\"url\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/author\\\/jamesgallagher\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"JavaScript Filter: A Step-By-Step Guide | Career Karma","description":"In JavaScript, it\u2019s common to want to filter out objects or run a calculation on an array. Learn more in this Career Karma article.","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:\/\/careerkarma.com\/blog\/javascript-filter-reduce\/","og_locale":"en_US","og_type":"article","og_title":"JavaScript Filter: A Step-By-Step Guide","og_description":"In JavaScript, it\u2019s common to want to filter out objects or run a calculation on an array. Learn more in this Career Karma article.","og_url":"https:\/\/careerkarma.com\/blog\/javascript-filter-reduce\/","og_site_name":"Career Karma","article_publisher":"http:\/\/facebook.com\/careerkarmaapp","article_published_time":"2020-10-22T11:12:00+00:00","article_modified_time":"2023-12-01T12:03:20+00:00","og_image":[{"width":1200,"height":675,"url":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/02\/javascript-filter-and-reduce.jpg","type":"image\/jpeg"}],"author":"James Gallagher","twitter_card":"summary_large_image","twitter_creator":"@career_karma","twitter_site":"@career_karma","twitter_misc":{"Written by":"James Gallagher","Est. reading time":"4 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/careerkarma.com\/blog\/javascript-filter-reduce\/#article","isPartOf":{"@id":"https:\/\/careerkarma.com\/blog\/javascript-filter-reduce\/"},"author":{"name":"James Gallagher","@id":"https:\/\/careerkarma.com\/blog\/#\/schema\/person\/e79364792443fbff794a144c67ec8e94"},"headline":"JavaScript Filter: A Step-By-Step Guide","datePublished":"2020-10-22T11:12:00+00:00","dateModified":"2023-12-01T12:03:20+00:00","mainEntityOfPage":{"@id":"https:\/\/careerkarma.com\/blog\/javascript-filter-reduce\/"},"wordCount":675,"commentCount":0,"image":{"@id":"https:\/\/careerkarma.com\/blog\/javascript-filter-reduce\/#primaryimage"},"thumbnailUrl":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/02\/javascript-filter-and-reduce.jpg","keywords":["tutorial"],"articleSection":["JavaScript"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/careerkarma.com\/blog\/javascript-filter-reduce\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/careerkarma.com\/blog\/javascript-filter-reduce\/","url":"https:\/\/careerkarma.com\/blog\/javascript-filter-reduce\/","name":"JavaScript Filter: A Step-By-Step Guide | Career Karma","isPartOf":{"@id":"https:\/\/careerkarma.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/careerkarma.com\/blog\/javascript-filter-reduce\/#primaryimage"},"image":{"@id":"https:\/\/careerkarma.com\/blog\/javascript-filter-reduce\/#primaryimage"},"thumbnailUrl":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/02\/javascript-filter-and-reduce.jpg","datePublished":"2020-10-22T11:12:00+00:00","dateModified":"2023-12-01T12:03:20+00:00","author":{"@id":"https:\/\/careerkarma.com\/blog\/#\/schema\/person\/e79364792443fbff794a144c67ec8e94"},"description":"In JavaScript, it\u2019s common to want to filter out objects or run a calculation on an array. Learn more in this Career Karma article.","breadcrumb":{"@id":"https:\/\/careerkarma.com\/blog\/javascript-filter-reduce\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/careerkarma.com\/blog\/javascript-filter-reduce\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/careerkarma.com\/blog\/javascript-filter-reduce\/#primaryimage","url":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/02\/javascript-filter-and-reduce.jpg","contentUrl":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/02\/javascript-filter-and-reduce.jpg","width":1200,"height":675,"caption":"JavaScript Filter and Reduce"},{"@type":"BreadcrumbList","@id":"https:\/\/careerkarma.com\/blog\/javascript-filter-reduce\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Blog","item":"https:\/\/careerkarma.com\/blog\/"},{"@type":"ListItem","position":2,"name":"JavaScript","item":"https:\/\/careerkarma.com\/blog\/javascript\/"},{"@type":"ListItem","position":3,"name":"JavaScript Filter: A Step-By-Step Guide"}]},{"@type":"WebSite","@id":"https:\/\/careerkarma.com\/blog\/#website","url":"https:\/\/careerkarma.com\/blog\/","name":"Career Karma","description":"Latest Coding Bootcamp News &amp; Career Hacks from Industry Insiders","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/careerkarma.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/careerkarma.com\/blog\/#\/schema\/person\/e79364792443fbff794a144c67ec8e94","name":"James Gallagher","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/01\/james-gallagher-150x150.jpg","url":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/01\/james-gallagher-150x150.jpg","contentUrl":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/01\/james-gallagher-150x150.jpg","caption":"James Gallagher"},"description":"James Gallagher is a self-taught programmer and the technical content manager at Career Karma. He has experience in range of programming languages and extensive expertise in Python, HTML, CSS, and JavaScript. James has written hundreds of programming tutorials, and he frequently contributes to publications like Codecademy, Treehouse, Repl.it, Afrotech, and others.","url":"https:\/\/careerkarma.com\/blog\/author\/jamesgallagher\/"}]}},"_links":{"self":[{"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/posts\/11868","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/users\/240"}],"replies":[{"embeddable":true,"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/comments?post=11868"}],"version-history":[{"count":0,"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/posts\/11868\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/media\/12331"}],"wp:attachment":[{"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/media?parent=11868"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/categories?post=11868"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/tags?post=11868"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}