{"id":11350,"date":"2022-07-21T14:27:21","date_gmt":"2022-07-21T11:27:21","guid":{"rendered":"https:\/\/elzero.org\/?p=11350"},"modified":"2022-07-21T14:54:17","modified_gmt":"2022-07-21T11:54:17","slug":"js-check-for-equality-for-array-elements","status":"publish","type":"post","link":"https:\/\/elzero.org\/old\/js-check-for-equality-for-array-elements\/","title":{"rendered":"\u062a\u0623\u0643\u062f \u0623\u0646 \u0639\u0646\u0627\u0635\u0631 \u0627\u0644 Array \u0643\u0644\u0647\u0627 \u0646\u0641\u0633 \u0627\u0644\u0639\u0646\u0635\u0631 \u0623\u0645 \u0644\u0627"},"content":{"rendered":"<div class=\"text\">\r\n\u062a\u0623\u0643\u062f \u0623\u0646 \u0639\u0646\u0627\u0635\u0631 \u0627\u0644 Array \u0643\u0644\u0647\u0627 \u0646\u0641\u0633 \u0627\u0644\u0639\u0646\u0635\u0631 \u0623\u0645 \u0644\u0627\r\n<\/div>\r\n\r\n<h3>\u0627\u0644\u0637\u0631\u064a\u0642\u0629 \u0627\u0644\u0623\u0648\u0644\u0649<\/h3>\r\n\r\n<div class=\"text\">\r\n\u0628\u0625\u0633\u062a\u062e\u062f\u0627\u0645 every \u0646\u0642\u0648\u0645 \u0628\u0645\u0642\u0627\u0631\u0646\u0629 \u0643\u0644 \u0639\u0646\u0635\u0631 \u0645\u0646 \u0639\u0646\u0627\u0635\u0631 \u0627\u0644 Array \u0628\u0627\u0644\u0639\u0646\u0635\u0631 \u0627\u0644\u0623\u0648\u0644 \u0648\u0625\u0630\u0627 \u062c\u0627\u0626\u062a \u0627\u0644\u0646\u062a\u064a\u062c\u0629 True \u0641\u064a \u0627\u0644\u0646\u0647\u0627\u064a\u0629 \u0645\u0639\u0646\u0627\u0647\u0627 \u0627\u0646 \u062c\u0645\u064a\u0639 \u0627\u0644\u0639\u0646\u0627\u0635\u0631 \u0647\u064a \u0646\u0641\u0633 \u0627\u0644\u0639\u0646\u0635\u0631\r\n<\/div>\r\n\r\n<script type=\"text\/plain\" class=\"language-javascript\">\r\nfunction checkEqualityMethodOne(arr) {\r\n  return arr.every((el) => el === arr[0]);\r\n}\r\n\r\nconsole.log(checkEqualityMethodOne([1, 1, 1, 1, 1, 1])); \/\/ True\r\nconsole.log(checkEqualityMethodOne([1, 1, 1, 1, 1, 3])); \/\/ False\r\n<\/script>\r\n\r\n<h3>\u0627\u0644\u0637\u0631\u064a\u0642\u0629 \u0627\u0644\u062b\u0627\u0646\u064a\u0629<\/h3>\r\n\r\n<div class=\"text\">\r\n\u0628\u0625\u0633\u062a\u062e\u062f\u0627\u0645 \u0627\u0644 Math Object Method \u0646\u0642\u0648\u0645 \u0628\u0645\u0642\u0627\u0631\u0646\u0629 \u0623\u0635\u063a\u0631 \u0639\u0646\u0635\u0631 \u0641\u064a \u0627\u0644 Array \u0645\u0639 \u0623\u0643\u0628\u0631 \u0639\u0646\u0635\u0631 \u0641\u064a \u0627\u0644 Array \u0648\u0625\u0630\u0627 \u0648\u062c\u062f\u0646\u0627 \u0623\u0646 \u0627\u0644\u0625\u062b\u0646\u064a\u0646 \u0648\u0627\u062d\u062f \u0645\u0639\u0646\u0627\u0647\u0627 \u0627\u0646 \u062c\u0645\u064a\u0639 \u0627\u0644\u0639\u0646\u0627\u0635\u0631 \u0647\u064a \u0646\u0641\u0633 \u0627\u0644\u0639\u0646\u0635\u0631\r\n<\/div>\r\n\r\n<script type=\"text\/plain\" class=\"language-javascript\">\r\nfunction checkEqualityMethodTwo(arr) {\r\n  return Math.min(...arr) === Math.max(...arr);\r\n}\r\n\r\nconsole.log(checkEqualityMethodTwo([1, 1, 1, 1, 1, 1])); \/\/ True\r\nconsole.log(checkEqualityMethodTwo([1, 1, 1, 1, 1, 3])); \/\/ False\r\n<\/script>\r\n\r\n<h3>\u0627\u0644\u0637\u0631\u064a\u0642\u0629 \u0627\u0644\u062b\u0627\u0644\u062b\u0629<\/h3>\r\n\r\n<div class=\"text\">\r\n\u0628\u0625\u0633\u062a\u062e\u062f\u0627\u0645 \u0627\u0644 Set \u0648\u0627\u0644\u062a\u064a \u0645\u0646 \u062e\u0644\u0627\u0644\u0647\u0627 \u0625\u0630\u0627 \u062a\u0645 \u0625\u0644\u063a\u0627\u0621 \u062c\u0645\u064a\u0639 \u0627\u0644\u0639\u0646\u0627\u0635\u0631 \u0627\u0644\u0645\u062a\u0634\u0627\u0628\u0647\u0629 \u0648\u062a\u0628\u0642\u0649 \u0639\u0646\u0635\u0631 \u0648\u0627\u062d\u062f \u0645\u0639\u0646\u0627\u0647 \u0623\u0646 \u062c\u0645\u064a\u0639 \u0627\u0644\u0639\u0646\u0627\u0635\u0631 \u0647\u064a \u0646\u0641\u0633 \u0627\u0644\u0639\u0646\u0635\u0631\r\n<\/div>\r\n\r\n<script type=\"text\/plain\" class=\"language-javascript\">\r\nfunction checkEqualityMethodThree(arr) {\r\n  return new Set(arr).size === 1;\r\n}\r\n\r\nconsole.log(checkEqualityMethodThree([1, 1, 1, 1, 1, 1])); \/\/ True\r\nconsole.log(checkEqualityMethodThree([1, 1, 1, 1, 1, 3])); \/\/ False\r\n<\/script>","protected":false},"excerpt":{"rendered":"<p>\u062a\u0623\u0643\u062f \u0623\u0646 \u0639\u0646\u0627\u0635\u0631 \u0627\u0644 Array \u0643\u0644\u0647\u0627 \u0646\u0641\u0633 \u0627\u0644\u0639\u0646\u0635\u0631 \u0623\u0645 \u0644\u0627<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[525],"tags":[557,1374,1376,902,825,1375],"class_list":["post-11350","post","type-post","status-publish","format-standard","hentry","category-javascript-tutorials","tag-array","tag-equality","tag-1376","tag-902","tag-825","tag-1375"],"_links":{"self":[{"href":"https:\/\/elzero.org\/old\/wp-json\/wp\/v2\/posts\/11350","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/elzero.org\/old\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/elzero.org\/old\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/elzero.org\/old\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/elzero.org\/old\/wp-json\/wp\/v2\/comments?post=11350"}],"version-history":[{"count":5,"href":"https:\/\/elzero.org\/old\/wp-json\/wp\/v2\/posts\/11350\/revisions"}],"predecessor-version":[{"id":11355,"href":"https:\/\/elzero.org\/old\/wp-json\/wp\/v2\/posts\/11350\/revisions\/11355"}],"wp:attachment":[{"href":"https:\/\/elzero.org\/old\/wp-json\/wp\/v2\/media?parent=11350"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/elzero.org\/old\/wp-json\/wp\/v2\/categories?post=11350"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/elzero.org\/old\/wp-json\/wp\/v2\/tags?post=11350"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}