{"id":1576,"date":"2018-11-01T17:37:57","date_gmt":"2018-11-01T17:37:57","guid":{"rendered":"http:\/\/corbdesign.com\/blog\/?p=1576"},"modified":"2018-11-01T17:37:57","modified_gmt":"2018-11-01T17:37:57","slug":"array-includes-is-not-a-function","status":"publish","type":"post","link":"https:\/\/corbinrose.com\/blog\/technology\/array-includes-is-not-a-function\/","title":{"rendered":"Array.Includes is not a function?"},"content":{"rendered":"\n<p>Support for older browsers that cannot run array.includes(&#8220;searchForThis&#8221;). Here is a workaround for that in your code!<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-js\" data-lang=\"JavaScript\"><code>if (![].includes) {\n  Array.prototype.includes = function (searchElement \/*, fromIndex*\/) {\n  &#39;use strict&#39;;\n  var O = Object(this);\n  var len = parseInt(O.length) || 0;\n  if (len === 0) {\n  return false;\n}\nvar n = parseInt(arguments[1]) || 0;\nvar k;\nif (n &amp;amp;gt;= 0) {\n  k = n;\n} else {\n  k = len + n;\nif (k &amp;amp;lt; 0) { k = 0; }\n}\nvar currentElement;\nwhile (k &amp;amp;lt; len) {\n  currentElement = O[k];\nif (searchElement === currentElement ||\n  (searchElement !== searchElement &amp; currentElement !== currentElement)) {\n  return true;\n}\nk++;\n}\n  return false;\n};\n}\n<\/code><\/pre><\/div>\n","protected":false},"excerpt":{"rendered":"<p>Support for older browsers that cannot run array.includes(&#8220;searchForThis&#8221;). Here is a workaround for that in your code!<\/p>\n","protected":false},"author":2,"featured_media":5537,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","_links_to":"","_links_to_target":""},"categories":[28,17],"tags":[],"class_list":["post-1576","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-coding","category-technology","clearfix","post-index"],"acf":[],"jetpack_featured_media_url":"https:\/\/corbinrose.com\/blog\/wp-content\/uploads\/2018\/11\/pexels-photo-4383298-2.jpeg","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/corbinrose.com\/blog\/wp-json\/wp\/v2\/posts\/1576","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/corbinrose.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/corbinrose.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/corbinrose.com\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/corbinrose.com\/blog\/wp-json\/wp\/v2\/comments?post=1576"}],"version-history":[{"count":0,"href":"https:\/\/corbinrose.com\/blog\/wp-json\/wp\/v2\/posts\/1576\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/corbinrose.com\/blog\/wp-json\/wp\/v2\/media\/5537"}],"wp:attachment":[{"href":"https:\/\/corbinrose.com\/blog\/wp-json\/wp\/v2\/media?parent=1576"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/corbinrose.com\/blog\/wp-json\/wp\/v2\/categories?post=1576"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/corbinrose.com\/blog\/wp-json\/wp\/v2\/tags?post=1576"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}