{"id":331428,"date":"2022-04-03T09:00:18","date_gmt":"2022-04-03T09:00:18","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=331428"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=331428","title":{"rendered":"<span>\u041a\u0430\u043a\u043e\u0439 \u0446\u0438\u043a\u043b \u0441\u0430\u043c\u044b\u0439 \u0431\u044b\u0441\u0442\u0440\u044b\u0439 \u0432 JavaScript?<\/span>"},"content":{"rendered":"<div><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u0412\u044b\u044f\u0441\u043d\u0438\u0442\u0435, \u043a\u0430\u043a\u043e\u0439 \u0446\u0438\u043a\u043b \u0438\u043b\u0438 \u0438\u0442\u0435\u0440\u0430\u0442\u043e\u0440 \u043f\u043e\u0434\u0445\u043e\u0434\u0438\u0442 \u0434\u043b\u044f \u0432\u0430\u0448\u0438\u0445 \u043d\u0443\u0436\u0434, \u0438 \u043f\u0440\u0435\u0434\u043e\u0442\u0432\u0440\u0430\u0442\u0438\u0442\u0435 \u0433\u043b\u0443\u043f\u044b\u0435 \u043e\u0448\u0438\u0431\u043a\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u043e\u0433\u0443\u0442 \u0443\u0445\u0443\u0434\u0448\u0438\u0442\u044c \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c.<\/p>\n<p>\u0412 \u0432\u0435\u0431 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0435 JavaScript &#8212; \u044d\u0442\u043e \u0441\u0435\u043d\u0441\u0430\u0446\u0438\u044f. \u042d\u0442\u043e \u043d\u0435 \u043f\u0440\u043e\u0441\u0442\u043e JS \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a \u043a\u0430\u043a NodeJS, React, Angular, Vue, \u0443 vanilla JS \u0442\u0430\u043a\u0436\u0435 \u0435\u0441\u0442\u044c \u0431\u043e\u043b\u044c\u0448\u0430\u044f \u0444\u0430\u043d\u0431\u0430\u0437\u0430. \u0421\u0435\u0439\u0447\u0430\u0441 \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u043f\u043e\u0433\u043e\u0432\u043e\u0440\u0438\u043c \u043e \u0441\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u043c JavaScript. \u041f\u043e\u0447\u0442\u0438 \u0432\u043e \u0432\u0441\u0435\u0445 \u044f\u0437\u044b\u043a\u0430\u0445 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0435\u0441\u0442\u044c \u0446\u0438\u043a\u043b\u044b. \u0412 \u0441\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u043c JS \u043c\u043e\u0436\u043d\u043e \u043e\u0447\u0435\u043d\u044c \u0433\u0438\u0431\u043a\u043e \u043f\u0435\u0440\u0435\u0431\u0440\u0430\u0442\u044c \u043a\u0430\u043a\u0438\u0435-\u043b\u0438\u0431\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f.<\/p>\n<p>\u0412\u043e\u043f\u0440\u043e\u0441 \u0432 \u0442\u043e\u043c, \u0437\u043d\u0430\u0435\u0442\u0435 \u043b\u0438 \u0432\u044b \u043a\u0430\u043a\u043e\u0439 \u0446\u0438\u043a\u043b \u0432\u0430\u043c \u043f\u043e\u0434\u0445\u043e\u0434\u0438\u0442 \u043b\u0443\u0447\u0448\u0435 \u0432\u0441\u0435\u0433\u043e. \u0412\u0435\u0434\u044c \u0435\u0441\u0442\u044c \u0438 for, \u0438 \u043e\u0431\u0440\u0430\u0442\u043d\u044b\u0439 for, \u0438 for&#8230;of, \u0438 foreach, \u0438 for&#8230;in, \u0438 for&#8230;await. \u042d\u0442\u0430 \u0441\u0442\u0430\u0442\u044c\u044f &#8212; \u043d\u0435\u043a\u0430\u044f \u0434\u0438\u0441\u043a\u0443\u0441\u0441\u0438\u044f \u043d\u0430 \u044d\u0442\u0443 \u0442\u0435\u043c\u0443.<\/p>\n<h3>\u041a\u0430\u043a\u043e\u0439 \u0446\u0438\u043a\u043b \u0441\u0430\u043c\u044b\u0439 \u0431\u044b\u0441\u0442\u0440\u044b\u0439?<\/h3>\n<p><strong><em>\u041e\u0442\u0432\u0435\u0442:<\/em><\/strong> <strong>\u043e\u0431\u0440\u0430\u0442\u043d\u044b\u0439 for<\/strong><\/p>\n<ul>\n<li>\n<p>\u041a\u043e\u0433\u0434\u0430 \u044f \u043f\u0440\u043e\u0432\u043e\u0434\u0438\u043b \u0442\u0435\u0441\u0442\u044b \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u043e, \u044f \u0431\u044b\u043b \u0443\u0434\u0438\u0432\u043b\u0435\u043d, \u0447\u0442\u043e \u043e\u0431\u0440\u0430\u0442\u043d\u044b\u0439 for \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0441\u0430\u043c\u044b\u043c \u0431\u044b\u0441\u0442\u0440\u044b\u043c \u0441\u0440\u0435\u0434\u0438 \u0432\u0441\u0435\u0445 \u0446\u0438\u043a\u043b\u043e\u0432. \u041d\u0438\u0436\u0435 \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u0438\u043c\u0435\u0440. \u0417\u0430\u043f\u0443\u0441\u043a\u0430\u0439\u0442\u0435 \u0446\u0438\u043a\u043b \u043f\u043e \u043c\u0430\u0441\u0441\u0438\u0432\u0443 \u0441 \u043e\u0434\u043d\u0438\u043c \u043c\u0438\u043b\u043b\u0438\u043e\u043d\u043e\u043c \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432.<\/p>\n<\/li>\n<li>\n<p><em>\u041f\u043e\u0436\u0430\u043b\u0443\u0439\u0441\u0442\u0430, \u043f\u043e\u043c\u043d\u0438\u0442\u0435, \u0447\u0442\u043e \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b console.time() \u0441\u0438\u043b\u044c\u043d\u043e \u0437\u0430\u0432\u0438\u0441\u044f\u0442 \u043e\u0442 \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u043e\u0439 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438. \u041f\u0440\u043e\u0432\u0435\u0440\u044c\u0442\u0435 \u0435\u0435 \u0442\u043e\u0447\u043d\u043e\u0441\u0442\u044c.<\/em><\/p>\n<\/li>\n<li>\n<p><em>const million = 1000000;<br \/>const arr = Array(million);<br \/>console.time(\u2018\u23f3\u2019);<br \/>for (let i = arr.length; i > 0; i \u2014 ) {} \/\/ for(reverse) :- 1.5ms<br \/>for (let i = 0; i &lt; arr.length; i++) {} \/\/ for :- 1.6ms<br \/>arr.forEach(v => v) \/\/ foreach :- 2.1ms<br \/>for (const v of arr) {} \/\/ for\u2026of :- 11.7ms<br \/>console.timeEnd(\u2018\u23f3\u2019);<\/em><\/p>\n<\/li>\n<li>\n<p>\u0423 \u043e\u0431\u044b\u0447\u043d\u043e\u0433\u043e for \u0438 \u043e\u0431\u0440\u0430\u0442\u043d\u043e\u0433\u043e \u043f\u043e\u0447\u0442\u0438 \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u043e\u0435 \u0432\u0440\u0435\u043c\u044f. \u0421\u0447\u0435\u0442\u0447\u0438\u043a \u0432 \u043e\u0431\u0440\u0430\u0442\u043d\u043e\u043c for \u0441\u0447\u0438\u0442\u0430\u0435\u0442\u00a0let<em>\u00a0i = arr.length \u0442\u043e\u043b\u044c\u043a\u043e <\/em>\u043e\u0434\u0438\u043d \u0440\u0430\u0437, \u0432\u043e\u0442 \u043e\u0442\u043a\u0443\u0434\u0430 \u0440\u0430\u0437\u043d\u0438\u0446\u0430 \u0432 0,1 \u043c\u0441. \u0412 \u043e\u0431\u044b\u0447\u043d\u043e\u043c \u0436\u0435 for \u043f\u043e\u0441\u043b\u0435 \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u043f\u0440\u043e\u0445\u043e\u0434\u0430, \u0435\u043c\u0443 \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0442\u044c \u0443\u0441\u043b\u043e\u0432\u0438\u0435 <em>i &lt; arr.length<\/em>. \u0412 \u0446\u0435\u043b\u043e\u043c, \u044d\u0442\u043e \u043f\u043e\u0447\u0442\u0438 \u043d\u0435 \u0438\u043c\u0435\u0435\u0442 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f, \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u043e\u0438\u0433\u043d\u043e\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c.<\/p>\n<\/li>\n<li>\n<p>\u0421 \u0434\u0440\u0443\u0433\u043e\u0439 \u0441\u0442\u043e\u0440\u043e\u043d\u044b <em>foreach\u00a0&#8212; <\/em>\u044d\u0442\u043e \u043c\u0435\u0442\u043e\u0434 \u043f\u0440\u043e\u0442\u043e\u0442\u0438\u043f\u0430 \u043c\u0430\u0441\u0441\u0438\u0432\u0430. \u0412 \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0438 \u0441 \u0446\u0438\u043a\u043b\u043e\u043c <em>for<\/em>, \u0434\u043b\u044f <em>foreach\u00a0<\/em>\u0438<em> for\u2026of<\/em> \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u0431\u043e\u043b\u044c\u0448\u0435 \u0432\u0440\u0435\u043c\u0435\u043d\u0438.<\/p>\n<\/li>\n<\/ul>\n<h3>\u041a\u0430\u043a\u0438\u0435 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0442 \u0446\u0438\u043a\u043b\u044b \u0438 \u043a\u043e\u0433\u0434\u0430 \u0438\u0445 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c?<\/h3>\n<ol>\n<li>\n<p><strong>\u041e\u0431\u044b\u0447\u043d\u044b\u0439 \u0438 \u043e\u0431\u0440\u0430\u0442\u043d\u044b\u0439 for<br \/><\/strong>\u041d\u0430\u0432\u0435\u0440\u043d\u043e\u0435 \u0432\u0441\u0435 \u0437\u043d\u0430\u043a\u043e\u043c\u044b \u0441 \u044d\u0442\u0438\u043c \u0432\u0438\u0434\u043e\u043c \u0446\u0438\u043a\u043b\u0430. \u0415\u0441\u043b\u0438 \u043d\u0430\u043c \u043d\u0430\u0434\u043e \u043f\u043e\u0432\u0442\u043e\u0440\u0438\u0442\u044c \u043a\u0430\u043a\u043e\u0439-\u0442\u043e \u0431\u043b\u043e\u043a \u043a\u043e\u0434\u0430 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u043e\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0440\u0430\u0437, \u043c\u044b \u043c\u043e\u0436\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c <em>for.<\/p>\n<p><\/em>\u0422\u0440\u0430\u0434\u0438\u0446\u0438\u043e\u043d\u043d\u043e for \u044d\u0442\u043e \u0441\u0430\u043c\u044b\u0439 \u0431\u044b\u0441\u0442\u0440\u044b\u0439 \u0446\u0438\u043a\u043b, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043c\u044b \u0432\u0441\u0435\u0433\u0434\u0430 \u0434\u043e\u043b\u0436\u043d\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0438\u043c\u0435\u043d\u043d\u043e \u0435\u0433\u043e, \u0432\u0435\u0440\u043d\u043e? \u041d\u0435 \u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u043e. \u041d\u0430 \u0432\u044b\u0431\u043e\u0440 \u0446\u0438\u043a\u043b\u0430 \u0432\u043b\u0438\u044f\u0435\u0442 \u043d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c. \u0412 \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u043c, \u0447\u0438\u0442\u0430\u0431\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u043a\u043e\u0434\u0430 \u0438\u0433\u0440\u0430\u0435\u0442 \u043a\u0443\u0434\u0430 \u0431\u043e\u043b\u0435\u0435 \u0432\u0430\u0436\u043d\u0443\u044e \u0440\u043e\u043b\u044c, \u0442\u0430\u043a \u0447\u0442\u043e \u0432\u044b\u0431\u0438\u0440\u0430\u0439\u0442\u0435 \u0442\u043e\u0442 \u0446\u0438\u043a\u043b, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u043e\u0434\u0445\u043e\u0434\u0438\u0442 \u0432\u0430\u0448\u0435\u043c\u0443 \u0441\u0442\u0438\u043b\u044e.<\/p>\n<\/li>\n<li>\n<p><strong>forEach<br \/><\/strong>\u041f\u043e\u0441\u043b\u0435 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430 \u043c\u0430\u0441\u0441\u0438\u0432\u0430, \u044d\u0442\u043e\u0442 \u043c\u0435\u0442\u043e\u0434 \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442 \u043a\u043e\u043b\u0431\u044d\u043a \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430. \u041a\u0440\u043e\u043c\u0435 \u0442\u043e\u0433\u043e, \u044d\u0442\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 \u0442\u0435\u043a\u0443\u0449\u0438\u0439 \u044d\u043b\u0435\u043c\u0435\u043d\u0442 \u0438 \u0435\u0433\u043e \u0438\u043d\u0434\u0435\u043a\u0441.<\/p>\n<p><em>foreach\u00a0<\/em>\u0442\u0430\u043a\u0436\u0435 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043a\u043b\u044e\u0447\u0435\u0432\u043e\u0435 \u0441\u043b\u043e\u0432\u043e <em>this\u00a0<\/em>\u043a\u0430\u043a \u043d\u0435\u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 \u0432 \u043a\u043e\u043b\u0431\u044d\u043a \u0444\u0443\u043d\u043a\u0446\u0438\u0438.<\/p>\n<p>const things = [\u2018have\u2019, \u2018fun\u2019, \u2018coding\u2019];<br \/>const callbackFun = (item, idex) => {<br \/>console.log(`${item} \u2014 ${index}`);<br \/>}<br \/>things.foreach(callbackFun);<br \/>o\/p:- have \u2014 0<br \/>fun \u2014 1<br \/>coding \u2014 2<\/p>\n<p>\u0412 JavaScript \u043f\u0440\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438 <em>foreach<\/em> \u043c\u044b \u043d\u0435 \u043c\u043e\u0436\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043f\u0440\u0435\u0438\u043c\u0443\u0449\u0435\u0441\u0442\u0432\u043e \u0441\u043e\u043a\u0440\u0430\u0449\u0435\u043d\u043d\u044b\u0445 \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u0439. \u041f\u043e\u0437\u0432\u043e\u043b\u044c\u0442\u0435 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u0432\u0430\u043c \u0441\u043e\u043a\u0440\u0430\u0449\u0435\u043d\u043d\u044b\u0435 \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f, \u0435\u0441\u043b\u0438 \u0432\u044b \u0435\u0449\u0435 \u0441 \u043d\u0438\u043c\u0438 \u043d\u0435 \u0437\u043d\u0430\u043a\u043e\u043c\u044b. \u041a\u043e\u0433\u0434\u0430 \u043c\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u043b\u043e\u0433\u0438\u0447\u0435\u0441\u043a\u0438\u0435 \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u044b, \u0442\u0430\u043a\u0438\u0435 \u043a\u0430\u043a <em>\u0418(&amp;&amp;)<\/em> \u0438\u043b\u0438 <em>\u0418\u041b\u0418(||), <\/em>\u043c\u044b \u043c\u043e\u0436\u0435\u043c \u043f\u0440\u043e\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u0438\u0442\u0435\u0440\u0430\u0446\u0438\u044e \u0446\u0438\u043a\u043b\u0430<\/p>\n<\/li>\n<li>\n<p><strong>For..of<br \/><\/strong>\u042d\u0442\u043e \u0446\u0438\u043a\u043b \u0431\u044b\u043b \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043d \u0432 ES6. \u0421 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u044d\u0442\u043e\u0433\u043e \u0446\u0438\u043a\u043b\u0430 \u043c\u043e\u0436\u043d\u043e \u0438\u0442\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u043f\u043e \u043b\u044e\u0431\u044b\u043c \u0438\u0442\u0435\u0440\u0438\u0440\u0443\u0435\u043c\u044b\u043c \u043e\u0431\u044a\u0435\u043a\u0442\u0430\u043c, \u0442\u0430\u043a\u0438\u043c \u043a\u0430\u043a \u043c\u0430\u0441\u0441\u0438\u0432, \u0441\u043b\u043e\u0432\u0430\u0440\u044c, \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e, \u0441\u0442\u0440\u043e\u043a\u0430 \u0438 \u0434\u0440. \u0412\u0434\u043e\u0431\u0430\u0432\u043e\u043a, \u043a\u043e\u0434 \u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0441\u044f \u0431\u043e\u043b\u0435\u0435 \u0447\u0438\u0442\u0430\u0431\u0435\u043b\u044c\u043d\u044b\u043c.<\/p>\n<p><em>const arr = [3, 5, 7];<br \/>const str = \u2018hello\u2019;<br \/>for (let i of arr) {<br \/>console.log(i); \/\/ logs 3, 5, 7<br \/>}<br \/>for (let i of str) {<br \/>console.log(i); \/\/ logs \u2018h\u2019, \u2018e\u2019, \u2018l\u2019, \u2018l\u2019, \u2018o\u2019<br \/>}<br \/><\/em>  <br \/><strong>\u0417\u0430\u043c\u0435\u0447\u0430\u043d\u0438\u0435<\/strong>: \u043d\u0435 \u0441\u043b\u0435\u0434\u0443\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c <em>for\u2026of<\/em>\u00a0\u0432 \u0433\u0435\u043d\u0435\u0440\u0430\u0442\u043e\u0440\u0430\u0445, \u0434\u0430\u0436\u0435 \u0435\u0441\u043b\u0438 <em>for\u2026of<\/em>\u00a0\u0437\u0430\u043a\u0430\u043d\u0447\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u0440\u0430\u043d\u044c\u0448\u0435. \u0413\u0435\u043d\u0435\u0440\u0430\u0442\u043e\u0440 \u0432\u044b\u043a\u043b\u044e\u0447\u0430\u0435\u0442\u0441\u044f \u043f\u043e\u0441\u043b\u0435 \u0432\u044b\u0445\u043e\u0434\u0430 \u0438\u0437 \u0446\u0438\u043a\u043b\u0430, \u0438 \u043f\u043e\u0432\u0442\u043e\u0440\u043d\u0430\u044f \u043f\u043e\u043f\u044b\u0442\u043a\u0430 \u0435\u0433\u043e \u0432\u044b\u0437\u043e\u0432\u0430 \u0431\u043e\u043b\u044c\u0448\u0435 \u043d\u0435 \u0434\u0430\u0441\u0442 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u043e\u0432.<\/p>\n<\/li>\n<li>\n<p><strong>For&#8230;in<br \/><\/strong>\u042d\u0442\u043e\u0442 \u0432\u0438\u0434 \u0446\u0438\u043a\u043b\u0430 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0441 \u043e\u0431\u044a\u0435\u043a\u0442\u0430\u043c\u0438, \u0443 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0435\u0441\u0442\u044c \u043a\u0430\u043a\u0438\u0435-\u043b\u0438\u0431\u043e \u043f\u0435\u0440\u0435\u0447\u0438\u0441\u043b\u044f\u0435\u043c\u044b\u0435 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430. \u0426\u0438\u043a\u043b <em>for\u2026in<\/em> \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0438\u043c\u0435\u043d\u0430 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u0438\u0445 \u0441\u0432\u043e\u0439\u0441\u0442\u0432 \u0432\u043c\u0435\u0441\u0442\u0435 \u0441 \u0447\u0438\u0441\u043b\u043e\u0432\u044b\u043c\u0438 \u0438\u043d\u0434\u0435\u043a\u0441\u0430\u043c\u0438 \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e\u0433\u043e \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430.<\/p>\n<p>\u041f\u043e \u044d\u0442\u043e\u0439 \u043f\u0440\u0438\u0447\u0438\u043d\u0435 \u043b\u0443\u0447\u0448\u0435 \u043f\u0435\u0440\u0435\u0431\u0438\u0440\u0430\u0442\u044c \u043c\u0430\u0441\u0441\u0438\u0432\u044b \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0446\u0438\u043a\u043b\u0430 <em>for<\/em>, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u0447\u0438\u0441\u043b\u043e\u0432\u043e\u0439 \u0438\u043d\u0434\u0435\u043a\u0441, \u0438\u0437-\u0437\u0430 \u0442\u043e\u0433\u043e, \u0447\u0442\u043e <em>for\u2026in<\/em> \u043f\u0435\u0440\u0435\u0431\u0438\u0440\u0430\u0435\u0442 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u0438\u0435 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430 \u0442\u0430\u043a \u0436\u0435 \u043a\u0430\u043a \u0438 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b \u043c\u0430\u0441\u0441\u0438\u0432\u0430, \u0434\u0430\u0436\u0435 \u0435\u0441\u043b\u0438 \u0432\u044b \u0438\u0437\u043c\u0435\u043d\u044f\u0435\u0442\u0435 \u043e\u0431\u044a\u0435\u043a\u0442 \u043c\u0430\u0441\u0441\u0438\u0432\u0430 (\u043f\u0443\u0442\u0435\u043c \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u0438\u0445 \u0441\u0432\u043e\u0439\u0441\u0442\u0432 \u0438\u043b\u0438 \u043c\u0435\u0442\u043e\u0434\u043e\u0432).<\/p>\n<p><em>const details = {firstName: \u2018john\u2019, lastName: \u2018Doe\u2019};<br \/>let fullName = \u2018\u2019;<br \/>for (let i in details) {<br \/>fullName += details[i] + \u2018 \u2018; \/\/ fullName: john doe<br \/>}<\/em><\/p>\n<\/li>\n<\/ol>\n<h4>For&#8230;in \u043f\u0440\u043e\u0442\u0438\u0432 for&#8230;of<\/h4>\n<p>For&#8230;in \u0438 for&#8230;of \u043e\u0442\u043b\u0438\u0447\u0430\u044e\u0442\u0441\u044f \u0432 \u043f\u0435\u0440\u0432\u0443\u044e \u043e\u0447\u0435\u0440\u0435\u0434\u044c \u0438\u0442\u0435\u0440\u0438\u0440\u0443\u0435\u043c\u044b\u043c\u0438 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430\u043c\u0438. For&#8230;in \u043f\u0440\u043e\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u043f\u043e \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430\u043c \u043e\u0431\u044a\u0435\u043a\u0442\u0430, \u0432 \u0442\u043e \u0432\u0440\u0435\u043c\u044f \u043a\u0430\u043a for&#8230;of \u043f\u0440\u043e\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u043f\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f\u043c.<\/p>\n<p><em>let arr= [4, 5, 6];<br \/>for (let i in arr) {<br \/>console.log(i); \/\/ \u20180\u2019, \u20181\u2019, \u20182\u2019<br \/>}<br \/>for (let i of arr) {<br \/>console.log(i); \/\/ \u20184\u2019, \u20185\u2019, \u20186\u2019<br \/>}<\/em><\/p>\n<h3>\u0417\u0430\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435<\/h3>\n<ul>\n<li>\n<p>\u0426\u0438\u043a\u043b for \u0441\u0430\u043c\u044b\u0439 \u0431\u044b\u0441\u0442\u0440\u044b\u0439, \u043d\u043e \u043f\u043b\u043e\u0445\u043e \u0447\u0438\u0442\u0430\u0435\u043c.<\/p>\n<\/li>\n<li>\n<p>forEach &#8212; \u0431\u044b\u0441\u0442\u0440\u044b\u0439, \u0430 \u0438\u0442\u0435\u0440\u0430\u0446\u0438\u044f \u043f\u043e\u0434\u043a\u043e\u043d\u0442\u0440\u043e\u043b\u044c\u043d\u0430.<\/p>\n<\/li>\n<li>\n<p>For&#8230;of \u0442\u0440\u0435\u0431\u0443\u0435\u0442 \u0432\u0440\u0435\u043c\u0435\u043d\u0438, \u043d\u043e \u043e\u043d \u0431\u043e\u043b\u0435\u0435 \u043f\u0440\u0438\u0432\u043b\u0435\u043a\u0430\u0442\u0435\u043b\u0435\u043d.<\/p>\n<\/li>\n<li>\n<p>For&#8230;in \u0442\u0440\u0435\u0431\u0443\u0435\u0442 \u0432\u0440\u0435\u043c\u0435\u043d\u0438, \u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u043c\u0435\u043d\u0435\u0435 \u0443\u0434\u043e\u0431\u0435\u043d.<\/p>\n<\/li>\n<\/ul>\n<p>\u041d\u0430\u043a\u043e\u043d\u0435\u0446, \u043c\u0443\u0434\u0440\u044b\u0439 \u0441\u043e\u0432\u0435\u0442 \u0434\u043b\u044f \u0432\u0430\u0441. \u041f\u0440\u0438\u043e\u0440\u0438\u0442\u0438\u0437\u0438\u0440\u0443\u0439\u0442\u0435 \u0447\u0438\u0442\u0430\u0431\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c. \u042d\u0442\u043e \u0432\u0430\u0436\u043d\u043e \u0434\u043b\u044f \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0430\u043d\u0438\u044f \u043a\u043e\u0434\u0430, \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e \u043a\u043e\u0433\u0434\u0430 \u0432\u044b \u0440\u0430\u0437\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u0442\u0435 \u043a\u0430\u043a\u0443\u044e-\u0442\u043e \u0441\u043b\u043e\u0436\u043d\u0443\u044e \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443, \u0438 \u043d\u0443\u0436\u043d\u043e \u043f\u0440\u0438 \u044d\u0442\u043e\u043c \u043f\u043e\u043c\u043d\u0438\u0442\u044c \u043f\u0440\u043e \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c.<\/p>\n<p>\u0418\u0437\u0431\u0435\u0433\u0430\u0439\u0442\u0435 \u043d\u0435\u043d\u0443\u0436\u043d\u044b\u0445 \u0434\u043e\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0439 \u0432 \u0432\u0430\u0448 \u043a\u043e\u0434, \u0442\u0430\u043a \u043a\u0430\u043a \u044d\u0442\u043e \u043c\u043e\u0436\u0435\u0442 \u0437\u0430\u043c\u0435\u0434\u043b\u0438\u0442\u044c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435.<\/p>\n<p>\u041d\u0430\u0441\u043b\u0430\u0436\u0434\u0430\u0439\u0442\u0435\u0441\u044c, \u043a\u043e\u0433\u0434\u0430 \u043a\u043e\u0434\u0438\u0442\u0435.?  <\/p>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"v-portal\" style=\"display:none;\"><\/div>\n<\/div>\n<p> <!----> <!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/post\/658797\/\"> https:\/\/habr.com\/ru\/post\/658797\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u0412\u044b\u044f\u0441\u043d\u0438\u0442\u0435, \u043a\u0430\u043a\u043e\u0439 \u0446\u0438\u043a\u043b \u0438\u043b\u0438 \u0438\u0442\u0435\u0440\u0430\u0442\u043e\u0440 \u043f\u043e\u0434\u0445\u043e\u0434\u0438\u0442 \u0434\u043b\u044f \u0432\u0430\u0448\u0438\u0445 \u043d\u0443\u0436\u0434, \u0438 \u043f\u0440\u0435\u0434\u043e\u0442\u0432\u0440\u0430\u0442\u0438\u0442\u0435 \u0433\u043b\u0443\u043f\u044b\u0435 \u043e\u0448\u0438\u0431\u043a\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u043e\u0433\u0443\u0442 \u0443\u0445\u0443\u0434\u0448\u0438\u0442\u044c \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c.<\/p>\n<p>\u0412 \u0432\u0435\u0431 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0435 JavaScript &#8212; \u044d\u0442\u043e \u0441\u0435\u043d\u0441\u0430\u0446\u0438\u044f. \u042d\u0442\u043e \u043d\u0435 \u043f\u0440\u043e\u0441\u0442\u043e JS \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a \u043a\u0430\u043a NodeJS, React, Angular, Vue, \u0443 vanilla JS \u0442\u0430\u043a\u0436\u0435 \u0435\u0441\u0442\u044c \u0431\u043e\u043b\u044c\u0448\u0430\u044f \u0444\u0430\u043d\u0431\u0430\u0437\u0430. \u0421\u0435\u0439\u0447\u0430\u0441 \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u043f\u043e\u0433\u043e\u0432\u043e\u0440\u0438\u043c \u043e \u0441\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u043c JavaScript. \u041f\u043e\u0447\u0442\u0438 \u0432\u043e \u0432\u0441\u0435\u0445 \u044f\u0437\u044b\u043a\u0430\u0445 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0435\u0441\u0442\u044c \u0446\u0438\u043a\u043b\u044b. \u0412 \u0441\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u043c JS \u043c\u043e\u0436\u043d\u043e \u043e\u0447\u0435\u043d\u044c \u0433\u0438\u0431\u043a\u043e \u043f\u0435\u0440\u0435\u0431\u0440\u0430\u0442\u044c \u043a\u0430\u043a\u0438\u0435-\u043b\u0438\u0431\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f.<\/p>\n<p>\u0412\u043e\u043f\u0440\u043e\u0441 \u0432 \u0442\u043e\u043c, \u0437\u043d\u0430\u0435\u0442\u0435 \u043b\u0438 \u0432\u044b \u043a\u0430\u043a\u043e\u0439 \u0446\u0438\u043a\u043b \u0432\u0430\u043c \u043f\u043e\u0434\u0445\u043e\u0434\u0438\u0442 \u043b\u0443\u0447\u0448\u0435 \u0432\u0441\u0435\u0433\u043e. \u0412\u0435\u0434\u044c \u0435\u0441\u0442\u044c \u0438 for, \u0438 \u043e\u0431\u0440\u0430\u0442\u043d\u044b\u0439 for, \u0438 for&#8230;of, \u0438 foreach, \u0438 for&#8230;in, \u0438 for&#8230;await. \u042d\u0442\u0430 \u0441\u0442\u0430\u0442\u044c\u044f &#8212; \u043d\u0435\u043a\u0430\u044f \u0434\u0438\u0441\u043a\u0443\u0441\u0441\u0438\u044f \u043d\u0430 \u044d\u0442\u0443 \u0442\u0435\u043c\u0443.<\/p>\n<h3>\u041a\u0430\u043a\u043e\u0439 \u0446\u0438\u043a\u043b \u0441\u0430\u043c\u044b\u0439 \u0431\u044b\u0441\u0442\u0440\u044b\u0439?<\/h3>\n<p><strong><em>\u041e\u0442\u0432\u0435\u0442:<\/em><\/strong> <strong>\u043e\u0431\u0440\u0430\u0442\u043d\u044b\u0439 for<\/strong><\/p>\n<ul>\n<li>\n<p>\u041a\u043e\u0433\u0434\u0430 \u044f \u043f\u0440\u043e\u0432\u043e\u0434\u0438\u043b \u0442\u0435\u0441\u0442\u044b \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u043e, \u044f \u0431\u044b\u043b \u0443\u0434\u0438\u0432\u043b\u0435\u043d, \u0447\u0442\u043e \u043e\u0431\u0440\u0430\u0442\u043d\u044b\u0439 for \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0441\u0430\u043c\u044b\u043c \u0431\u044b\u0441\u0442\u0440\u044b\u043c \u0441\u0440\u0435\u0434\u0438 \u0432\u0441\u0435\u0445 \u0446\u0438\u043a\u043b\u043e\u0432. \u041d\u0438\u0436\u0435 \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u0438\u043c\u0435\u0440. \u0417\u0430\u043f\u0443\u0441\u043a\u0430\u0439\u0442\u0435 \u0446\u0438\u043a\u043b \u043f\u043e \u043c\u0430\u0441\u0441\u0438\u0432\u0443 \u0441 \u043e\u0434\u043d\u0438\u043c \u043c\u0438\u043b\u043b\u0438\u043e\u043d\u043e\u043c \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432.<\/p>\n<\/li>\n<li>\n<p><em>\u041f\u043e\u0436\u0430\u043b\u0443\u0439\u0441\u0442\u0430, \u043f\u043e\u043c\u043d\u0438\u0442\u0435, \u0447\u0442\u043e \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b console.time() \u0441\u0438\u043b\u044c\u043d\u043e \u0437\u0430\u0432\u0438\u0441\u044f\u0442 \u043e\u0442 \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u043e\u0439 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438. \u041f\u0440\u043e\u0432\u0435\u0440\u044c\u0442\u0435 \u0435\u0435 \u0442\u043e\u0447\u043d\u043e\u0441\u0442\u044c.<\/em><\/p>\n<\/li>\n<li>\n<p><em>const million = 1000000;<br \/>const arr = Array(million);<br \/>console.time(\u2018\u23f3\u2019);<br \/>for (let i = arr.length; i > 0; i \u2014 ) {} \/\/ for(reverse) :- 1.5ms<br \/>for (let i = 0; i &lt; arr.length; i++) {} \/\/ for :- 1.6ms<br \/>arr.forEach(v => v) \/\/ foreach :- 2.1ms<br \/>for (const v of arr) {} \/\/ for\u2026of :- 11.7ms<br \/>console.timeEnd(\u2018\u23f3\u2019);<\/em><\/p>\n<\/li>\n<li>\n<p>\u0423 \u043e\u0431\u044b\u0447\u043d\u043e\u0433\u043e for \u0438 \u043e\u0431\u0440\u0430\u0442\u043d\u043e\u0433\u043e \u043f\u043e\u0447\u0442\u0438 \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u043e\u0435 \u0432\u0440\u0435\u043c\u044f. \u0421\u0447\u0435\u0442\u0447\u0438\u043a \u0432 \u043e\u0431\u0440\u0430\u0442\u043d\u043e\u043c for \u0441\u0447\u0438\u0442\u0430\u0435\u0442\u00a0let<em>\u00a0i = arr.length \u0442\u043e\u043b\u044c\u043a\u043e <\/em>\u043e\u0434\u0438\u043d \u0440\u0430\u0437, \u0432\u043e\u0442 \u043e\u0442\u043a\u0443\u0434\u0430 \u0440\u0430\u0437\u043d\u0438\u0446\u0430 \u0432 0,1 \u043c\u0441. \u0412 \u043e\u0431\u044b\u0447\u043d\u043e\u043c \u0436\u0435 for \u043f\u043e\u0441\u043b\u0435 \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u043f\u0440\u043e\u0445\u043e\u0434\u0430, \u0435\u043c\u0443 \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0442\u044c \u0443\u0441\u043b\u043e\u0432\u0438\u0435 <em>i &lt; arr.length<\/em>. \u0412 \u0446\u0435\u043b\u043e\u043c, \u044d\u0442\u043e \u043f\u043e\u0447\u0442\u0438 \u043d\u0435 \u0438\u043c\u0435\u0435\u0442 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f, \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u043e\u0438\u0433\u043d\u043e\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c.<\/p>\n<\/li>\n<li>\n<p>\u0421 \u0434\u0440\u0443\u0433\u043e\u0439 \u0441\u0442\u043e\u0440\u043e\u043d\u044b <em>foreach\u00a0&#8212; <\/em>\u044d\u0442\u043e \u043c\u0435\u0442\u043e\u0434 \u043f\u0440\u043e\u0442\u043e\u0442\u0438\u043f\u0430 \u043c\u0430\u0441\u0441\u0438\u0432\u0430. \u0412 \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0438 \u0441 \u0446\u0438\u043a\u043b\u043e\u043c <em>for<\/em>, \u0434\u043b\u044f <em>foreach\u00a0<\/em>\u0438<em> for\u2026of<\/em> \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u0431\u043e\u043b\u044c\u0448\u0435 \u0432\u0440\u0435\u043c\u0435\u043d\u0438.<\/p>\n<\/li>\n<\/ul>\n<h3>\u041a\u0430\u043a\u0438\u0435 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0442 \u0446\u0438\u043a\u043b\u044b \u0438 \u043a\u043e\u0433\u0434\u0430 \u0438\u0445 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c?<\/h3>\n<ol>\n<li>\n<p><strong>\u041e\u0431\u044b\u0447\u043d\u044b\u0439 \u0438 \u043e\u0431\u0440\u0430\u0442\u043d\u044b\u0439 for<br \/><\/strong>\u041d\u0430\u0432\u0435\u0440\u043d\u043e\u0435 \u0432\u0441\u0435 \u0437\u043d\u0430\u043a\u043e\u043c\u044b \u0441 \u044d\u0442\u0438\u043c \u0432\u0438\u0434\u043e\u043c \u0446\u0438\u043a\u043b\u0430. \u0415\u0441\u043b\u0438 \u043d\u0430\u043c \u043d\u0430\u0434\u043e \u043f\u043e\u0432\u0442\u043e\u0440\u0438\u0442\u044c \u043a\u0430\u043a\u043e\u0439-\u0442\u043e \u0431\u043b\u043e\u043a \u043a\u043e\u0434\u0430 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u043e\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0440\u0430\u0437, \u043c\u044b \u043c\u043e\u0436\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c <em>for.<\/p>\n<p><\/em>\u0422\u0440\u0430\u0434\u0438\u0446\u0438\u043e\u043d\u043d\u043e for \u044d\u0442\u043e \u0441\u0430\u043c\u044b\u0439 \u0431\u044b\u0441\u0442\u0440\u044b\u0439 \u0446\u0438\u043a\u043b, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043c\u044b \u0432\u0441\u0435\u0433\u0434\u0430 \u0434\u043e\u043b\u0436\u043d\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0438\u043c\u0435\u043d\u043d\u043e \u0435\u0433\u043e, \u0432\u0435\u0440\u043d\u043e? \u041d\u0435 \u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u043e. \u041d\u0430 \u0432\u044b\u0431\u043e\u0440 \u0446\u0438\u043a\u043b\u0430 \u0432\u043b\u0438\u044f\u0435\u0442 \u043d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c. \u0412 \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u043c, \u0447\u0438\u0442\u0430\u0431\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u043a\u043e\u0434\u0430 \u0438\u0433\u0440\u0430\u0435\u0442 \u043a\u0443\u0434\u0430 \u0431\u043e\u043b\u0435\u0435 \u0432\u0430\u0436\u043d\u0443\u044e \u0440\u043e\u043b\u044c, \u0442\u0430\u043a \u0447\u0442\u043e \u0432\u044b\u0431\u0438\u0440\u0430\u0439\u0442\u0435 \u0442\u043e\u0442 \u0446\u0438\u043a\u043b, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u043e\u0434\u0445\u043e\u0434\u0438\u0442 \u0432\u0430\u0448\u0435\u043c\u0443 \u0441\u0442\u0438\u043b\u044e.<\/p>\n<\/li>\n<li>\n<p><strong>forEach<br \/><\/strong>\u041f\u043e\u0441\u043b\u0435 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430 \u043c\u0430\u0441\u0441\u0438\u0432\u0430, \u044d\u0442\u043e\u0442 \u043c\u0435\u0442\u043e\u0434 \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442 \u043a\u043e\u043b\u0431\u044d\u043a \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430. \u041a\u0440\u043e\u043c\u0435 \u0442\u043e\u0433\u043e, \u044d\u0442\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 \u0442\u0435\u043a\u0443\u0449\u0438\u0439 \u044d\u043b\u0435\u043c\u0435\u043d\u0442 \u0438 \u0435\u0433\u043e \u0438\u043d\u0434\u0435\u043a\u0441.<\/p>\n<p><em>foreach\u00a0<\/em>\u0442\u0430\u043a\u0436\u0435 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043a\u043b\u044e\u0447\u0435\u0432\u043e\u0435 \u0441\u043b\u043e\u0432\u043e <em>this\u00a0<\/em>\u043a\u0430\u043a \u043d\u0435\u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 \u0432 \u043a\u043e\u043b\u0431\u044d\u043a \u0444\u0443\u043d\u043a\u0446\u0438\u0438.<\/p>\n<p>const things = [\u2018have\u2019, \u2018fun\u2019, \u2018coding\u2019];<br \/>const callbackFun = (item, idex) => {<br \/>console.log(`${item} \u2014 ${index}`);<br \/>}<br \/>things.foreach(callbackFun);<br \/>o\/p:- have \u2014 0<br \/>fun \u2014 1<br \/>coding \u2014 2<\/p>\n<p>\u0412 JavaScript \u043f\u0440\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438 <em>foreach<\/em> \u043c\u044b \u043d\u0435 \u043c\u043e\u0436\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043f\u0440\u0435\u0438\u043c\u0443\u0449\u0435\u0441\u0442\u0432\u043e \u0441\u043e\u043a\u0440\u0430\u0449\u0435\u043d\u043d\u044b\u0445 \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u0439. \u041f\u043e\u0437\u0432\u043e\u043b\u044c\u0442\u0435 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u0432\u0430\u043c \u0441\u043e\u043a\u0440\u0430\u0449\u0435\u043d\u043d\u044b\u0435 \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f, \u0435\u0441\u043b\u0438 \u0432\u044b \u0435\u0449\u0435 \u0441 \u043d\u0438\u043c\u0438 \u043d\u0435 \u0437\u043d\u0430\u043a\u043e\u043c\u044b. \u041a\u043e\u0433\u0434\u0430 \u043c\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u043b\u043e\u0433\u0438\u0447\u0435\u0441\u043a\u0438\u0435 \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u044b, \u0442\u0430\u043a\u0438\u0435 \u043a\u0430\u043a <em>\u0418(&amp;&amp;)<\/em> \u0438\u043b\u0438 <em>\u0418\u041b\u0418(||), <\/em>\u043c\u044b \u043c\u043e\u0436\u0435\u043c \u043f\u0440\u043e\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u0438\u0442\u0435\u0440\u0430\u0446\u0438\u044e \u0446\u0438\u043a\u043b\u0430<\/p>\n<\/li>\n<li>\n<p><strong>For..of<br \/><\/strong>\u042d\u0442\u043e \u0446\u0438\u043a\u043b \u0431\u044b\u043b \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043d \u0432 ES6. \u0421 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u044d\u0442\u043e\u0433\u043e \u0446\u0438\u043a\u043b\u0430 \u043c\u043e\u0436\u043d\u043e \u0438\u0442\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u043f\u043e \u043b\u044e\u0431\u044b\u043c \u0438\u0442\u0435\u0440\u0438\u0440\u0443\u0435\u043c\u044b\u043c \u043e\u0431\u044a\u0435\u043a\u0442\u0430\u043c, \u0442\u0430\u043a\u0438\u043c \u043a\u0430\u043a \u043c\u0430\u0441\u0441\u0438\u0432, \u0441\u043b\u043e\u0432\u0430\u0440\u044c, \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e, \u0441\u0442\u0440\u043e\u043a\u0430 \u0438 \u0434\u0440. \u0412\u0434\u043e\u0431\u0430\u0432\u043e\u043a, \u043a\u043e\u0434 \u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0441\u044f \u0431\u043e\u043b\u0435\u0435 \u0447\u0438\u0442\u0430\u0431\u0435\u043b\u044c\u043d\u044b\u043c.<\/p>\n<p><em>const arr = [3, 5, 7];<br \/>const str = \u2018hello\u2019;<br \/>for (let i of arr) {<br \/>console.log(i); \/\/ logs 3, 5, 7<br \/>}<br \/>for (let i of str) {<br \/>console.log(i); \/\/ logs \u2018h\u2019, \u2018e\u2019, \u2018l\u2019, \u2018l\u2019, \u2018o\u2019<br \/>}<br \/><\/em>  <br \/><strong>\u0417\u0430\u043c\u0435\u0447\u0430\u043d\u0438\u0435<\/strong>: \u043d\u0435 \u0441\u043b\u0435\u0434\u0443\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c <em>for\u2026of<\/em>\u00a0\u0432 \u0433\u0435\u043d\u0435\u0440\u0430\u0442\u043e\u0440\u0430\u0445, \u0434\u0430\u0436\u0435 \u0435\u0441\u043b\u0438 <em>for\u2026of<\/em>\u00a0\u0437\u0430\u043a\u0430\u043d\u0447\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u0440\u0430\u043d\u044c\u0448\u0435. \u0413\u0435\u043d\u0435\u0440\u0430\u0442\u043e\u0440 \u0432\u044b\u043a\u043b\u044e\u0447\u0430\u0435\u0442\u0441\u044f \u043f\u043e\u0441\u043b\u0435 \u0432\u044b\u0445\u043e\u0434\u0430 \u0438\u0437 \u0446\u0438\u043a\u043b\u0430, \u0438 \u043f\u043e\u0432\u0442\u043e\u0440\u043d\u0430\u044f \u043f\u043e\u043f\u044b\u0442\u043a\u0430 \u0435\u0433\u043e \u0432\u044b\u0437\u043e\u0432\u0430 \u0431\u043e\u043b\u044c\u0448\u0435 \u043d\u0435 \u0434\u0430\u0441\u0442 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u043e\u0432.<\/p>\n<\/li>\n<li>\n<p><strong>For&#8230;in<br \/><\/strong>\u042d\u0442\u043e\u0442 \u0432\u0438\u0434 \u0446\u0438\u043a\u043b\u0430 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0441 \u043e\u0431\u044a\u0435\u043a\u0442\u0430\u043c\u0438, \u0443 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0435\u0441\u0442\u044c \u043a\u0430\u043a\u0438\u0435-\u043b\u0438\u0431\u043e \u043f\u0435\u0440\u0435\u0447\u0438\u0441\u043b\u044f\u0435\u043c\u044b\u0435 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430. \u0426\u0438\u043a\u043b <em>for\u2026in<\/em> \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0438\u043c\u0435\u043d\u0430 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u0438\u0445 \u0441\u0432\u043e\u0439\u0441\u0442\u0432 \u0432\u043c\u0435\u0441\u0442\u0435 \u0441 \u0447\u0438\u0441\u043b\u043e\u0432\u044b\u043c\u0438 \u0438\u043d\u0434\u0435\u043a\u0441\u0430\u043c\u0438 \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e\u0433\u043e \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430.<\/p>\n<p>\u041f\u043e \u044d\u0442\u043e\u0439 \u043f\u0440\u0438\u0447\u0438\u043d\u0435 \u043b\u0443\u0447\u0448\u0435 \u043f\u0435\u0440\u0435\u0431\u0438\u0440\u0430\u0442\u044c \u043c\u0430\u0441\u0441\u0438\u0432\u044b \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0446\u0438\u043a\u043b\u0430 <em>for<\/em>, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u0447\u0438\u0441\u043b\u043e\u0432\u043e\u0439 \u0438\u043d\u0434\u0435\u043a\u0441, \u0438\u0437-\u0437\u0430 \u0442\u043e\u0433\u043e, \u0447\u0442\u043e <em>for\u2026in<\/em> \u043f\u0435\u0440\u0435\u0431\u0438\u0440\u0430\u0435\u0442 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u0438\u0435 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430 \u0442\u0430\u043a \u0436\u0435 \u043a\u0430\u043a \u0438 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b \u043c\u0430\u0441\u0441\u0438\u0432\u0430, \u0434\u0430\u0436\u0435 \u0435\u0441\u043b\u0438 \u0432\u044b \u0438\u0437\u043c\u0435\u043d\u044f\u0435\u0442\u0435 \u043e\u0431\u044a\u0435\u043a\u0442 \u043c\u0430\u0441\u0441\u0438\u0432\u0430 (\u043f\u0443\u0442\u0435\u043c \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u0438\u0445 \u0441\u0432\u043e\u0439\u0441\u0442\u0432 \u0438\u043b\u0438 \u043c\u0435\u0442\u043e\u0434\u043e\u0432).<\/p>\n<p><em>const details = {firstName: \u2018john\u2019, lastName: \u2018Doe\u2019};<br \/>let fullName = \u2018\u2019;<br \/>for (let i in details) {<br \/>fullName += details[i] + \u2018 \u2018; \/\/ fullName: john doe<br \/>}<\/em><\/p>\n<\/li>\n<\/ol>\n<h4>For&#8230;in \u043f\u0440\u043e\u0442\u0438\u0432 for&#8230;of<\/h4>\n<p>For&#8230;in \u0438 for&#8230;of \u043e\u0442\u043b\u0438\u0447\u0430\u044e\u0442\u0441\u044f \u0432 \u043f\u0435\u0440\u0432\u0443\u044e \u043e\u0447\u0435\u0440\u0435\u0434\u044c \u0438\u0442\u0435\u0440\u0438\u0440\u0443\u0435\u043c\u044b\u043c\u0438 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430\u043c\u0438. For&#8230;in \u043f\u0440\u043e\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u043f\u043e \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430\u043c \u043e\u0431\u044a\u0435\u043a\u0442\u0430, \u0432 \u0442\u043e \u0432\u0440\u0435\u043c\u044f \u043a\u0430\u043a for&#8230;of \u043f\u0440\u043e\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u043f\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f\u043c.<\/p>\n<p><em>let arr= [4, 5, 6];<br \/>for (let i in arr) {<br \/>console.log(i); \/\/ \u20180\u2019, \u20181\u2019, \u20182\u2019<br \/>}<br \/>for (let i of arr) {<br \/>console.log(i); \/\/ \u20184\u2019, \u20185\u2019, \u20186\u2019<br \/>}<\/em><\/p>\n<h3>\u0417\u0430\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435<\/h3>\n<ul>\n<li>\n<p>\u0426\u0438\u043a\u043b for \u0441\u0430\u043c\u044b\u0439 \u0431\u044b\u0441\u0442\u0440\u044b\u0439, \u043d\u043e \u043f\u043b\u043e\u0445\u043e \u0447\u0438\u0442\u0430\u0435\u043c.<\/p>\n<\/li>\n<li>\n<p>forEach &#8212; \u0431\u044b\u0441\u0442\u0440\u044b\u0439, \u0430 \u0438\u0442\u0435\u0440\u0430\u0446\u0438\u044f \u043f\u043e\u0434\u043a\u043e\u043d\u0442\u0440\u043e\u043b\u044c\u043d\u0430.<\/p>\n<\/li>\n<li>\n<p>For&#8230;of \u0442\u0440\u0435\u0431\u0443\u0435\u0442 \u0432\u0440\u0435\u043c\u0435\u043d\u0438, \u043d\u043e \u043e\u043d \u0431\u043e\u043b\u0435\u0435 \u043f\u0440\u0438\u0432\u043b\u0435\u043a\u0430\u0442\u0435\u043b\u0435\u043d.<\/p>\n<\/li>\n<li>\n<p>For&#8230;in \u0442\u0440\u0435\u0431\u0443\u0435\u0442 \u0432\u0440\u0435\u043c\u0435\u043d\u0438, \u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u043c\u0435\u043d\u0435\u0435 \u0443\u0434\u043e\u0431\u0435\u043d.<\/p>\n<\/li>\n<\/ul>\n<p>\u041d\u0430\u043a\u043e\u043d\u0435\u0446, \u043c\u0443\u0434\u0440\u044b\u0439 \u0441\u043e\u0432\u0435\u0442 \u0434\u043b\u044f \u0432\u0430\u0441. \u041f\u0440\u0438\u043e\u0440\u0438\u0442\u0438\u0437\u0438\u0440\u0443\u0439\u0442\u0435 \u0447\u0438\u0442\u0430\u0431\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c. \u042d\u0442\u043e \u0432\u0430\u0436\u043d\u043e \u0434\u043b\u044f \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0430\u043d\u0438\u044f \u043a\u043e\u0434\u0430, \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e \u043a\u043e\u0433\u0434\u0430 \u0432\u044b \u0440\u0430\u0437\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u0442\u0435 \u043a\u0430\u043a\u0443\u044e-\u0442\u043e \u0441\u043b\u043e\u0436\u043d\u0443\u044e \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443, \u0438 \u043d\u0443\u0436\u043d\u043e \u043f\u0440\u0438 \u044d\u0442\u043e\u043c \u043f\u043e\u043c\u043d\u0438\u0442\u044c \u043f\u0440\u043e \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c.<\/p>\n<p>\u0418\u0437\u0431\u0435\u0433\u0430\u0439\u0442\u0435 \u043d\u0435\u043d\u0443\u0436\u043d\u044b\u0445 \u0434\u043e\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0439 \u0432 \u0432\u0430\u0448 \u043a\u043e\u0434, \u0442\u0430\u043a \u043a\u0430\u043a \u044d\u0442\u043e \u043c\u043e\u0436\u0435\u0442 \u0437\u0430\u043c\u0435\u0434\u043b\u0438\u0442\u044c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435.<\/p>\n<p>\u041d\u0430\u0441\u043b\u0430\u0436\u0434\u0430\u0439\u0442\u0435\u0441\u044c, \u043a\u043e\u0433\u0434\u0430 \u043a\u043e\u0434\u0438\u0442\u0435.?  <\/p>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"v-portal\" style=\"display:none;\"><\/div>\n<\/div>\n<p> <!----> <!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/post\/658797\/\"> https:\/\/habr.com\/ru\/post\/658797\/<\/a><br \/><\/br><\/br><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-331428","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/331428","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=331428"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/331428\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=331428"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=331428"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=331428"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}