{"id":28748,"date":"2022-04-26T16:23:43","date_gmt":"2022-04-26T10:53:43","guid":{"rendered":"https:\/\/tutorial.eyehunts.com\/?p=28748"},"modified":"2023-07-21T17:31:38","modified_gmt":"2023-07-21T12:01:38","slug":"javascript-if-in-array-example-code","status":"publish","type":"post","link":"https:\/\/tutorial.eyehunts.com\/js\/javascript-if-in-array-example-code\/","title":{"rendered":"JavaScript if in array | Example code"},"content":{"rendered":"\n<p>Use JavaScript <a href=\"https:\/\/tutorial.eyehunts.com\/js\/javascript-includes-method-array-and-string-example\/\">includes() method<\/a> to check if the value in Array. This method returns <code>true<\/code> if an array contains a specified value otherwise returns <code>false<\/code> if the value is not found.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>array.includes(element, start)<\/code><\/pre>\n\n\n\n<p><strong>Note<\/strong>: The <code>includes()<\/code> method is case-sensitive.<\/p>\n\n\n\n<div style=\"height:30px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>JavaScript if in array<\/strong><\/h2>\n\n\n\n<p>Simple example code check if the string is in array js.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;!DOCTYPE html&gt;\n&lt;html&gt;\n&lt;body&gt;\n\n  &lt;script&gt;\n\n    var colors = &#91;\"red\", \"blue\", \"green\"];\n    var hasRed = colors.includes(\"red\"); \n    var hasYellow = colors.includes(\"yellow\"); \n\n    console.log(hasRed)\n    console.log(hasYellow)\n\n  &lt;\/script&gt;\n\n&lt;\/body&gt;\n&lt;\/html&gt; \n<\/code><\/pre>\n\n\n\n<p><strong>Output<\/strong>:<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"197\" height=\"86\" src=\"https:\/\/i0.wp.com\/tutorial.eyehunts.com\/wp-content\/uploads\/2022\/04\/JavaScript-if-in-array.jpg?resize=197%2C86&#038;ssl=1\" alt=\"JavaScript if in array\" class=\"wp-image-28776\"\/><\/figure><\/div>\n\n\n<p>You can also use <a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/JavaScript\/Reference\/Global_Objects\/Array\/indexOf\"><code>Array#indexOf<\/code><\/a>, which is less direct, but doesn&#8217;t require polyfills for outdated browsers.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>console.log(&#91;'joe', 'jane', 'mary'].indexOf('jane') &gt;= 0); \/\/true<\/code><\/pre>\n\n\n\n<p><strong>Note<\/strong>: <code>Array.includes()<\/code> is more straightforward and easier to use for checking the presence of an element in an array. However, if you need the index of the element, then <code>Array.indexOf()<\/code> is more appropriate.<\/p>\n\n\n\n<p>Many frameworks also offer similar methods:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>jQuery: <a href=\"https:\/\/api.jquery.com\/jquery.inarray\/\"><code>$.inArray(value, array, [fromIndex])<\/code><\/a><\/li>\n\n\n\n<li>Underscore.js: <a href=\"https:\/\/underscorejs.org\/#contains\"><code>_.contains(array, value)<\/code><\/a> (also aliased as <code>_.include<\/code> and <code>_.includes<\/code>)<\/li>\n\n\n\n<li>Dojo Toolkit: <a href=\"https:\/\/dojotoolkit.org\/reference-guide\/1.10\/dojo\/indexOf.html\"><code>dojo.indexOf(array, value, [fromIndex, findLast])<\/code><\/a><\/li>\n\n\n\n<li>Prototype: <a href=\"http:\/\/api.prototypejs.org\/language\/Array\/prototype\/indexOf\/\"><code>array.indexOf(value)<\/code><\/a><\/li>\n\n\n\n<li>MooTools: <a href=\"https:\/\/mootools.net\/core\/docs\/1.6.0\/Types\/Array#Array:indexOf\"><code>array.indexOf(value)<\/code><\/a><\/li>\n\n\n\n<li>MochiKit: <a href=\"http:\/\/mochi.github.io\/mochikit\/doc\/html\/MochiKit\/Base.html#fn-findvalue\"><code>findValue(array, value)<\/code><\/a><\/li>\n\n\n\n<li>MS Ajax: <a href=\"https:\/\/web.archive.org\/web\/20140819232945\/http:\/\/www.asp.net\/ajaxlibrary\/Reference.Array-indexOf-Function.ashx\"><code>array.indexOf(value)<\/code><\/a><\/li>\n\n\n\n<li>Ext: <a href=\"https:\/\/docs.sencha.com\/extjs\/7.5.1\/modern\/Ext.Array.html#method-contains\"><code>Ext.Array.contains(array, value)<\/code><\/a><\/li>\n\n\n\n<li>Lodash: <a href=\"https:\/\/lodash.com\/docs#includes\"><code>_.includes(array, value, [from])<\/code><\/a> (is <code>_.contains<\/code> prior 4.0.0)<\/li>\n\n\n\n<li>Ramda: <a href=\"https:\/\/ramdajs.com\/docs\/#includes\"><code>R.includes(value, array)<\/code><\/a><\/li>\n<\/ul>\n\n\n\n<p><strong>Note<\/strong>: that some frameworks implement this as a function, while others add the function to the array prototype.<\/p>\n\n\n\n<div style=\"height:30px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<p>Do comment if you have any doubts or suggestions on this JS Array topic.<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\"><p><strong>Note:<\/strong>&nbsp;The<strong>&nbsp;All JS Examples codes&nbsp;<\/strong>are&nbsp;tested on the Firefox browser and the Chrome browser.<\/p><p>OS:&nbsp;<strong>Windows 10<\/strong><\/p><p>Code: HTML 5 Version<\/p><\/blockquote>\n","protected":false},"excerpt":{"rendered":"<p>Use JavaScript includes() method to check if the value in Array. This method returns true if an array contains a specified value otherwise returns false if the value is not found. Note: The includes() method is case-sensitive. JavaScript if in array Simple example code check if the string is in array js. Output: You can&hellip;&nbsp;<a href=\"https:\/\/tutorial.eyehunts.com\/js\/javascript-if-in-array-example-code\/\" rel=\"bookmark\">Read More &raquo;<span class=\"screen-reader-text\">JavaScript if in array | Example code<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"neve_meta_sidebar":"","neve_meta_container":"","neve_meta_enable_content_width":"","neve_meta_content_width":0,"neve_meta_title_alignment":"","neve_meta_author_avatar":"","neve_post_elements_order":"","neve_meta_disable_header":"","neve_meta_disable_footer":"","neve_meta_disable_title":"","jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[69],"tags":[106],"post_series":[],"class_list":["post-28748","post","type-post","status-publish","format-standard","hentry","category-js","tag-js-array"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.1.1 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>JavaScript if in array | Example code<\/title>\n<meta name=\"description\" content=\"Use JavaScript includes a method to check if the value in Array. This method returns true if an array contains a specified value otherwise\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/tutorial.eyehunts.com\/js\/javascript-if-in-array-example-code\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"JavaScript if in array | Example code\" \/>\n<meta property=\"og:description\" content=\"Use JavaScript includes a method to check if the value in Array. This method returns true if an array contains a specified value otherwise\" \/>\n<meta property=\"og:url\" content=\"https:\/\/tutorial.eyehunts.com\/js\/javascript-if-in-array-example-code\/\" \/>\n<meta property=\"og:site_name\" content=\"Tutorial\" \/>\n<meta property=\"article:published_time\" content=\"2022-04-26T10:53:43+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2023-07-21T12:01:38+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/tutorial.eyehunts.com\/wp-content\/uploads\/2022\/04\/JavaScript-if-in-array.jpg\" \/>\n<meta name=\"author\" content=\"Rohit\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Rohit\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"1 minute\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/tutorial.eyehunts.com\/js\/javascript-if-in-array-example-code\/\",\"url\":\"https:\/\/tutorial.eyehunts.com\/js\/javascript-if-in-array-example-code\/\",\"name\":\"JavaScript if in array | Example code\",\"isPartOf\":{\"@id\":\"https:\/\/tutorial.eyehunts.com\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/tutorial.eyehunts.com\/js\/javascript-if-in-array-example-code\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/tutorial.eyehunts.com\/js\/javascript-if-in-array-example-code\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/tutorial.eyehunts.com\/wp-content\/uploads\/2022\/04\/JavaScript-if-in-array.jpg\",\"datePublished\":\"2022-04-26T10:53:43+00:00\",\"dateModified\":\"2023-07-21T12:01:38+00:00\",\"author\":{\"@id\":\"https:\/\/tutorial.eyehunts.com\/#\/schema\/person\/69ca2cb8c13fdce0ee5b39d6175119b1\"},\"description\":\"Use JavaScript includes a method to check if the value in Array. This method returns true if an array contains a specified value otherwise\",\"breadcrumb\":{\"@id\":\"https:\/\/tutorial.eyehunts.com\/js\/javascript-if-in-array-example-code\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/tutorial.eyehunts.com\/js\/javascript-if-in-array-example-code\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/tutorial.eyehunts.com\/js\/javascript-if-in-array-example-code\/#primaryimage\",\"url\":\"https:\/\/i0.wp.com\/tutorial.eyehunts.com\/wp-content\/uploads\/2022\/04\/JavaScript-if-in-array.jpg?fit=197%2C86&ssl=1\",\"contentUrl\":\"https:\/\/i0.wp.com\/tutorial.eyehunts.com\/wp-content\/uploads\/2022\/04\/JavaScript-if-in-array.jpg?fit=197%2C86&ssl=1\",\"width\":197,\"height\":86},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/tutorial.eyehunts.com\/js\/javascript-if-in-array-example-code\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/tutorial.eyehunts.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"JavaScript if in array | Example code\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/tutorial.eyehunts.com\/#website\",\"url\":\"https:\/\/tutorial.eyehunts.com\/\",\"name\":\"Tutorial\",\"description\":\"By EyeHunts\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/tutorial.eyehunts.com\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/tutorial.eyehunts.com\/#\/schema\/person\/69ca2cb8c13fdce0ee5b39d6175119b1\",\"name\":\"Rohit\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/tutorial.eyehunts.com\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/tutorial.eyehunts.com\/wp-content\/litespeed\/avatar\/2b27529b86d6dfb5336897e07c93a827.jpg?ver=1777979855\",\"contentUrl\":\"https:\/\/tutorial.eyehunts.com\/wp-content\/litespeed\/avatar\/2b27529b86d6dfb5336897e07c93a827.jpg?ver=1777979855\",\"caption\":\"Rohit\"},\"description\":\"Degree in Computer Science and Engineer: App Developer and has multiple Programming languages experience. Enthusiasm for technology &amp; like learning technical.\",\"url\":\"https:\/\/tutorial.eyehunts.com\/author\/rohit\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"JavaScript if in array | Example code","description":"Use JavaScript includes a method to check if the value in Array. This method returns true if an array contains a specified value otherwise","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:\/\/tutorial.eyehunts.com\/js\/javascript-if-in-array-example-code\/","og_locale":"en_US","og_type":"article","og_title":"JavaScript if in array | Example code","og_description":"Use JavaScript includes a method to check if the value in Array. This method returns true if an array contains a specified value otherwise","og_url":"https:\/\/tutorial.eyehunts.com\/js\/javascript-if-in-array-example-code\/","og_site_name":"Tutorial","article_published_time":"2022-04-26T10:53:43+00:00","article_modified_time":"2023-07-21T12:01:38+00:00","og_image":[{"url":"https:\/\/tutorial.eyehunts.com\/wp-content\/uploads\/2022\/04\/JavaScript-if-in-array.jpg","type":"","width":"","height":""}],"author":"Rohit","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Rohit","Est. reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/tutorial.eyehunts.com\/js\/javascript-if-in-array-example-code\/","url":"https:\/\/tutorial.eyehunts.com\/js\/javascript-if-in-array-example-code\/","name":"JavaScript if in array | Example code","isPartOf":{"@id":"https:\/\/tutorial.eyehunts.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/tutorial.eyehunts.com\/js\/javascript-if-in-array-example-code\/#primaryimage"},"image":{"@id":"https:\/\/tutorial.eyehunts.com\/js\/javascript-if-in-array-example-code\/#primaryimage"},"thumbnailUrl":"https:\/\/tutorial.eyehunts.com\/wp-content\/uploads\/2022\/04\/JavaScript-if-in-array.jpg","datePublished":"2022-04-26T10:53:43+00:00","dateModified":"2023-07-21T12:01:38+00:00","author":{"@id":"https:\/\/tutorial.eyehunts.com\/#\/schema\/person\/69ca2cb8c13fdce0ee5b39d6175119b1"},"description":"Use JavaScript includes a method to check if the value in Array. This method returns true if an array contains a specified value otherwise","breadcrumb":{"@id":"https:\/\/tutorial.eyehunts.com\/js\/javascript-if-in-array-example-code\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/tutorial.eyehunts.com\/js\/javascript-if-in-array-example-code\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/tutorial.eyehunts.com\/js\/javascript-if-in-array-example-code\/#primaryimage","url":"https:\/\/i0.wp.com\/tutorial.eyehunts.com\/wp-content\/uploads\/2022\/04\/JavaScript-if-in-array.jpg?fit=197%2C86&ssl=1","contentUrl":"https:\/\/i0.wp.com\/tutorial.eyehunts.com\/wp-content\/uploads\/2022\/04\/JavaScript-if-in-array.jpg?fit=197%2C86&ssl=1","width":197,"height":86},{"@type":"BreadcrumbList","@id":"https:\/\/tutorial.eyehunts.com\/js\/javascript-if-in-array-example-code\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/tutorial.eyehunts.com\/"},{"@type":"ListItem","position":2,"name":"JavaScript if in array | Example code"}]},{"@type":"WebSite","@id":"https:\/\/tutorial.eyehunts.com\/#website","url":"https:\/\/tutorial.eyehunts.com\/","name":"Tutorial","description":"By EyeHunts","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/tutorial.eyehunts.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/tutorial.eyehunts.com\/#\/schema\/person\/69ca2cb8c13fdce0ee5b39d6175119b1","name":"Rohit","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/tutorial.eyehunts.com\/#\/schema\/person\/image\/","url":"https:\/\/tutorial.eyehunts.com\/wp-content\/litespeed\/avatar\/2b27529b86d6dfb5336897e07c93a827.jpg?ver=1777979855","contentUrl":"https:\/\/tutorial.eyehunts.com\/wp-content\/litespeed\/avatar\/2b27529b86d6dfb5336897e07c93a827.jpg?ver=1777979855","caption":"Rohit"},"description":"Degree in Computer Science and Engineer: App Developer and has multiple Programming languages experience. Enthusiasm for technology &amp; like learning technical.","url":"https:\/\/tutorial.eyehunts.com\/author\/rohit\/"}]}},"jetpack_featured_media_url":"","jetpack-related-posts":[{"id":9023,"url":"https:\/\/tutorial.eyehunts.com\/js\/javascript-array-includes-method-check-if-a-value-exists\/","url_meta":{"origin":28748,"position":0},"title":"JavaScript array includes method | check if a value exists","author":"Rohit","date":"June 22, 2020","format":false,"excerpt":"JavaScript array includes is used to check an element is exists in the array or not. It's an\u00a0inbuilt function and returns true if the element is present in Array. Syntax array.includes(element, start) Parameter element:- A element value want to search.start:- Array position to start the search given element. Optional and\u2026","rel":"","context":"In &quot;JavaScript&quot;","block_context":{"text":"JavaScript","link":"https:\/\/tutorial.eyehunts.com\/category\/js\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/tutorial.eyehunts.com\/wp-content\/uploads\/2020\/06\/JavaScript-array-includes-method.png?resize=350%2C200&ssl=1","width":350,"height":200},"classes":[]},{"id":24977,"url":"https:\/\/tutorial.eyehunts.com\/js\/javascript-charcodeat-method-get-the-unicode-value-of-char\/","url_meta":{"origin":28748,"position":1},"title":"JavaScript charCodeAt Method | Get the Unicode value of char","author":"Rohit","date":"February 11, 2022","format":false,"excerpt":"JavaScript charCodeAt() is used to get a Unicode value for a character at a specific position in a string. This method returns an integer between 0 and 65535 representing the UTF-16 code unit at the given index. string.charCodeAt(index) Note: If index is out of range, charCodeAt() returns NaN. The following\u2026","rel":"","context":"In &quot;JavaScript&quot;","block_context":{"text":"JavaScript","link":"https:\/\/tutorial.eyehunts.com\/category\/js\/"},"img":{"alt_text":"JavaScript charCodeAt Method","src":"https:\/\/i0.wp.com\/tutorial.eyehunts.com\/wp-content\/uploads\/2022\/02\/JavaScript-charCodeAt-Method.jpg?resize=350%2C200&ssl=1","width":350,"height":200},"classes":[]},{"id":28247,"url":"https:\/\/tutorial.eyehunts.com\/js\/javascript-remove-item-from-array-by-value\/","url_meta":{"origin":28748,"position":2},"title":"JavaScript remove item from array by value","author":"Rohit","date":"April 27, 2023","format":false,"excerpt":"In JavaScript, you can remove an item from an array by its value using either the Array.filter() method or the indexOf() method combined with the splice() method. The filter() method creates a new array that only includes the items from the original array that pass a condtions, while the indexOf()\u2026","rel":"","context":"In &quot;JavaScript&quot;","block_context":{"text":"JavaScript","link":"https:\/\/tutorial.eyehunts.com\/category\/js\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/tutorial.eyehunts.com\/wp-content\/uploads\/2023\/04\/JavaScript-remove-item-from-array-by-value.jpg?resize=350%2C200&ssl=1","width":350,"height":200},"classes":[]},{"id":38478,"url":"https:\/\/tutorial.eyehunts.com\/js\/javascript-contains-array\/","url_meta":{"origin":28748,"position":3},"title":"JavaScript contains array","author":"Rohit","date":"April 20, 2023","format":false,"excerpt":"JavaScript includes() method is used to determine whether an array contains a certain value or not and returns a boolean value indicating the result. JavaScript contains an array example Simple example code determines whether an array includes a certain value or not. <!DOCTYPE html> <html> <body> <script> const myArray =\u2026","rel":"","context":"In &quot;JavaScript&quot;","block_context":{"text":"JavaScript","link":"https:\/\/tutorial.eyehunts.com\/category\/js\/"},"img":{"alt_text":"JavaScript contains array","src":"https:\/\/i0.wp.com\/tutorial.eyehunts.com\/wp-content\/uploads\/2023\/04\/JavaScript-contains-array.jpg?resize=350%2C200&ssl=1","width":350,"height":200},"classes":[]},{"id":37047,"url":"https:\/\/tutorial.eyehunts.com\/js\/javascript-set-values-method\/","url_meta":{"origin":28748,"position":4},"title":"JavaScript set values() method","author":"Rohit","date":"March 17, 2023","format":false,"excerpt":"JavaScript set values() method returns a new Iterator object that contains the values for each element in the Set object in insertion order. setObj.values() Note: the values() method returns an iterator object, so we need to use the next() method to retrieve each value. setIter.next().value JavaScript set values() examples Simple\u2026","rel":"","context":"In &quot;JavaScript&quot;","block_context":{"text":"JavaScript","link":"https:\/\/tutorial.eyehunts.com\/category\/js\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/tutorial.eyehunts.com\/wp-content\/uploads\/2023\/03\/JavaScript-set-values-method.jpg?resize=350%2C200&ssl=1","width":350,"height":200},"classes":[]},{"id":37016,"url":"https:\/\/tutorial.eyehunts.com\/js\/javascript-set-method\/","url_meta":{"origin":28748,"position":5},"title":"JavaScript set() method","author":"Rohit","date":"March 16, 2023","format":false,"excerpt":"JavaScript set() method is a set method, which is used to add a new element to the set. The Set object is a built-in data structure that represents an unordered collection of unique values. The syntax of the set() method is as follows: mySet.set(value); JavaScript set() method example A simple\u2026","rel":"","context":"In &quot;JavaScript&quot;","block_context":{"text":"JavaScript","link":"https:\/\/tutorial.eyehunts.com\/category\/js\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/tutorial.eyehunts.com\/wp-content\/uploads\/2023\/03\/JavaScript-set-method.jpg?resize=350%2C200&ssl=1","width":350,"height":200},"classes":[]}],"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/tutorial.eyehunts.com\/wp-json\/wp\/v2\/posts\/28748","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/tutorial.eyehunts.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/tutorial.eyehunts.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/tutorial.eyehunts.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/tutorial.eyehunts.com\/wp-json\/wp\/v2\/comments?post=28748"}],"version-history":[{"count":1,"href":"https:\/\/tutorial.eyehunts.com\/wp-json\/wp\/v2\/posts\/28748\/revisions"}],"predecessor-version":[{"id":41205,"href":"https:\/\/tutorial.eyehunts.com\/wp-json\/wp\/v2\/posts\/28748\/revisions\/41205"}],"wp:attachment":[{"href":"https:\/\/tutorial.eyehunts.com\/wp-json\/wp\/v2\/media?parent=28748"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/tutorial.eyehunts.com\/wp-json\/wp\/v2\/categories?post=28748"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/tutorial.eyehunts.com\/wp-json\/wp\/v2\/tags?post=28748"},{"taxonomy":"post_series","embeddable":true,"href":"https:\/\/tutorial.eyehunts.com\/wp-json\/wp\/v2\/post_series?post=28748"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}