{"id":296880,"date":"2020-01-09T09:00:14","date_gmt":"2020-01-09T09:00:14","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=296880"},"modified":"-0001-11-30T00:00:00","modified_gmt":"2020-01-09T09:00:14","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=296880","title":{"rendered":"\u0427\u0442\u043e \u0434\u043e\u0431\u0430\u0432\u044f\u0442 \u0432 JavaScript \u0443\u0436\u0435 \u0432 2020 \u0433\u043e\u0434\u0443"},"content":{"rendered":"\n<div class=\"post__text post__text-html js-mediator-article\" id=\"post-content-body\" data-io-article-url=\"https:\/\/habr.com\/ru\/post\/483118\/\">\n<p>\u041d\u0435\u0434\u0430\u0432\u043d\u043e \u043e\u043f\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u044b\u0439 \u0434\u043e\u0441\u0442\u0443\u043f \u043a \u0430\u0442\u0442\u0440\u0438\u0431\u0443\u0442\u0430\u043c (<em>Optional Chaining<\/em>) \u0438 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u0434\u043b\u044f \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u043e\u0432 (<em>Nullish Coalescing<\/em>) \u043f\u0435\u0440\u0435\u0448\u043b\u0438 \u043d\u0430 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0439, \u0447\u0435\u0442\u0432\u0451\u0440\u0442\u044b\u0439 \u044d\u0442\u0430\u043f \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430 TC39.<\/p>\n<p>  <\/p>\n<p>\u041d\u0430 \u043f\u0440\u0430\u043a\u0442\u0438\u043a\u0435 \u044d\u0442\u043e \u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442, \u0447\u0442\u043e \u044d\u0442\u0438 \u0438 \u0434\u0440\u0443\u0433\u0438\u0435 <a href=\"https:\/\/github.com\/tc39\/proposals\/blob\/master\/finished-proposals.md\">\u043d\u043e\u0432\u043e\u0432\u0432\u0435\u0434\u0435\u043d\u0438\u044f<\/a> \u0441\u0442\u0430\u043d\u0443\u0442 \u0447\u0430\u0441\u0442\u044c\u044e \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u0430 JavaScript \u0443\u0436\u0435 \u0432 \u044d\u0442\u043e\u043c, 2020 \u0433\u043e\u0434\u0443. \u0418\u0445 \u043c\u044b \u0438 \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0432 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435.<\/p>\n<p>  <\/p>\n<p><em>\u041e\u0442\u0441\u043b\u0435\u0436\u0438\u0432\u0430\u0442\u044c \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0443 \u0431\u0440\u0430\u0443\u0437\u0435\u0440\u0430\u043c\u0438 \u043c\u043e\u0436\u043d\u043e <a href=\"https:\/\/kangax.github.io\/compat-table\/es2016plus\/\">\u0437\u0434\u0435\u0441\u044c<\/a> (\u00ab2020 features\u00bb) \u2014 \u043f\u0440\u0438\u043c. \u043f\u0435\u0440\u0435\u0432.<\/em><\/p>\n<p>  <\/p>\n<p><em><\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/e8c\/27f\/6b0\/e8c27f6b0fcf596a06a31135d937c73e.png\"><\/div>\n<p><\/em><\/p>\n<p><a name=\"habracut\"><\/a>  <\/p>\n<h2><a href=\"https:\/\/github.com\/tc39\/proposal-string-matchall\">String.prototype.matchAll<\/a><\/h2>\n<p>  <\/p>\n<p>\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u00ab\u043b\u0438\u043f\u043a\u0438\u0445\u00bb (<em>sticky<\/em>) \u0438\u043b\u0438 \u0433\u043b\u043e\u0431\u0430\u043b\u044c\u043d\u044b\u0445 \u0440\u0435\u0433\u0443\u043b\u044f\u0440\u043d\u044b\u0445 \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u0439, \u043a\u043e\u0433\u0434\u0430 \u043d\u0430\u0434\u043e \u0437\u0430\u0445\u0432\u0430\u0442\u0438\u0442\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0433\u0440\u0443\u043f\u043f \u043d\u0430 \u043e\u0434\u043d\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u0435, \u043c\u043e\u0436\u0435\u0442 \u043e\u043a\u0430\u0437\u0430\u0442\u044c\u0441\u044f \u043d\u0435\u0442\u0440\u0438\u0432\u0438\u0430\u043b\u044c\u043d\u044b\u043c.<\/p>\n<p>  <\/p>\n<p><em>String.prototype.match<\/em> \u043d\u0435 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0437\u0430\u0445\u0432\u0430\u0447\u0435\u043d\u043d\u044b\u0435 \u0433\u0440\u0443\u043f\u043f\u044b \u043f\u0440\u0438 \u043d\u0430\u043b\u0438\u0447\u0438\u0438 \u0433\u043b\u043e\u0431\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u0444\u043b\u0430\u0433\u0430, \u0430 \u0431\u0435\u0437 \u043d\u0435\u0433\u043e \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u0435\u0440\u0432\u043e\u0435 \u043f\u043e\u043b\u043d\u043e\u0435 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0438\u0435 \u0448\u0430\u0431\u043b\u043e\u043d\u0443 \u0438 \u0435\u0433\u043e \u0433\u0440\u0443\u043f\u043f\u044b.<\/p>\n<p>  <\/p>\n<p><em>\u041f\u0440\u0438\u043c\u0435\u0440:<\/em><\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">let regexp = \/t(e)(st(\\d?))\/g; let str = 'test1test2'; const results = str.match(regexp); console.log(results);<\/code><\/pre>\n<p>  <\/p>\n<p><em>\u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0441 \u0444\u043b\u0430\u0433\u043e\u043c \u00abg\u00bb<\/em><\/p>\n<p>  <\/p>\n<div style=\"text-align:center;\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/528\/510\/9a4\/5285109a434b86fd2c717aaa0353415d.png\" width=\"492\" height=\"68\"><\/div>\n<p><em>\u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0431\u0435\u0437 \u0444\u043b\u0430\u0433\u0430 \u00abg\u00bb<\/em>  <\/p>\n<div style=\"text-align:center;\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/a14\/ee1\/28d\/a14ee128df6d5f105ade9fa42aeebe81.png\" width=\"636\" height=\"64\"><\/div>\n<p>  <\/p>\n<p>\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 <em>String.prototype.matchAll<\/em> \u0433\u0430\u0440\u0430\u043d\u0442\u0438\u0440\u0443\u0435\u0442, \u0447\u0442\u043e \u0431\u0443\u0434\u0443\u0442 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0435\u043d\u044b \u0432\u0441\u0435 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0438\u044f \u0438 \u0438\u0445 \u0433\u0440\u0443\u043f\u043f\u044b.<\/p>\n<p>  <\/p>\n<p><em>\u041f\u0440\u0438\u043c\u0435\u0440:<\/em><\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">let regexp = \/t(e)(st(\\d?))\/g; let str = 'test1test2'; let array = [...str.matchAll(regexp)]; console.log(array);<\/code><\/pre>\n<p>  <\/p>\n<p><em>\u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442:<\/em><\/p>\n<p>  <\/p>\n<div style=\"text-align:center;\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/4dd\/b2f\/92a\/4ddb2f92a9122b47355a04802557752f.png\" width=\"1316\" height=\"70\"><\/div>\n<p>  <\/p>\n<h2><a href=\"https:\/\/github.com\/tc39\/proposal-bigint\">BigInt<\/a><\/h2>\n<p>  <\/p>\n<p>\u0414\u043e \u043f\u043e\u044f\u0432\u043b\u0435\u043d\u0438\u044f <em>BigInt<\/em> \u043d\u0430\u0438\u0431\u043e\u043b\u044c\u0448\u0435\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435, \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u043c\u043e\u0435 <em>Number<\/em>, \u0431\u044b\u043b\u043e \u0440\u0430\u0432\u043d\u043e 2\u2075\u00b3-1 (MAX_SAFE_INTEGER). \u0422\u0435\u043f\u0435\u0440\u044c \u0432 JavaScript \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u0438\u043c\u0438\u0442\u0438\u0432, \u0441\u043f\u043e\u0441\u043e\u0431\u043d\u044b\u0439 \u043f\u0440\u0435\u0432\u0437\u043e\u0439\u0442\u0438 \u043b\u0438\u043c\u0438\u0442.<\/p>\n<p>  <\/p>\n<p>\u0421\u043e\u0437\u0434\u0430\u0442\u044c <em>BigInt<\/em> \u043c\u043e\u0436\u043d\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u0432 &#8216;n&#8217; \u043a \u0447\u0438\u0441\u043b\u0443 \u0438\u043b\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044e BigInt().<\/p>\n<p>  <\/p>\n<p><em>\u041f\u0440\u0438\u043c\u0435\u0440:<\/em><\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">let bigInt = 4n console.log(bigInt * bigInt)<\/code><\/pre>\n<p>  <\/p>\n<ul>\n<li><em>BigInt<\/em> \u043d\u0435 \u044d\u043a\u0432\u0438\u0432\u0430\u043b\u0435\u043d\u0442\u0435\u043d <em>Number<\/em>, \u043d\u043e \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043f\u0440\u0438\u0432\u0435\u0434\u0451\u043d \u043a \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0435\u043c\u0443.<\/li>\n<li>\u041f\u0440\u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0438 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0439 \u0432\u0440\u043e\u0434\u0435 \u0434\u0435\u043b\u0435\u043d\u0438\u044f, \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0431\u0443\u0434\u0435\u0442 \u043e\u043a\u0440\u0443\u0433\u043b\u0451\u043d \u0434\u043e 0.<\/li>\n<li>\u041d\u0435\u043b\u044c\u0437\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0441 <em>Number<\/em> \u0431\u0435\u0437 \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d\u0438\u044f \u0442\u0438\u043f\u043e\u0432.<\/li>\n<\/ul>\n<p>  <\/p>\n<p><em>\u041f\u043e\u043f\u044b\u0442\u043a\u0430 \u0441\u043b\u043e\u0436\u0438\u0442\u044c BigInt \u0441 \u0447\u0438\u0441\u043b\u043e\u043c&#8230;<\/em><\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">let bigInt = 4n + 2 console.log(bigInt)<\/code><\/pre>\n<p>  <\/p>\n<p><em>\u2026 \u043f\u0440\u0438\u0432\u043e\u0434\u0438\u0442 \u043a \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044e:<\/em><\/p>\n<p>  <\/p>\n<div style=\"text-align:center;\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/7c6\/32d\/078\/7c632d07828092222ae6e1788e2ac62f.png\" width=\"1176\" height=\"98\"><\/div>\n<p>  <\/p>\n<h2><a href=\"https:\/\/github.com\/tc39\/proposal-global\">globalThis<\/a><\/h2>\n<p>  <\/p>\n<p>\u0414\u043e\u0441\u0442\u0443\u043f \u043a \u0433\u043b\u043e\u0431\u0430\u043b\u044c\u043d\u044b\u043c \u043e\u0431\u044a\u0435\u043a\u0442\u0430\u043c \u0432 \u043c\u0438\u0440\u0435 JavaScript \u0432\u0441\u0435\u0433\u0434\u0430 \u0431\u044b\u043b \u0433\u043e\u043b\u043e\u0432\u043d\u043e\u0439 \u0431\u043e\u043b\u044c\u044e. \u0412\u044b \u0434\u043e\u043b\u0436\u043d\u044b \u0431\u044b\u0442\u044c \u0437\u043d\u0430\u043a\u043e\u043c\u044b \u0441\u043e \u0441\u043f\u0435\u0446\u0438\u0444\u0438\u0447\u0435\u0441\u043a\u0438\u043c \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0441\u043e\u043c \u0434\u043b\u044f \u043e\u043a\u0440\u0443\u0436\u0435\u043d\u0438\u044f, \u0447\u0442\u043e \u0441\u043e\u0437\u0434\u0430\u0451\u0442 \u043b\u0438\u0448\u043d\u0438\u0435 \u0442\u0440\u0443\u0434\u043d\u043e\u0441\u0442\u0438 \u043f\u0440\u0438 \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u0438 \u043f\u0435\u0440\u0435\u043d\u043e\u0441\u0438\u043c\u043e\u0433\u043e \u043a\u043e\u0434\u0430 \u0438 \u043f\u0440\u0438\u0432\u043e\u0434\u0438\u0442 \u043a \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0447\u0442\u043e-\u0442\u043e \u0432\u0440\u043e\u0434\u0435 getGlobal.<\/p>\n<p>  <\/p>\n<p><em>\u041f\u0440\u0438\u043c\u0435\u0440:<\/em><\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">var getGlobal = function () {    if (typeof self !== 'undefined') { return self; }    if (typeof window !== 'undefined') { return window; }    if (typeof global !== 'undefined') { return global; }    throw new Error('no global object found');  };   var globals = getGlobal(); <\/code><\/pre>\n<p>  <\/p>\n<p>\u0421 \u043f\u043e\u044f\u0432\u043b\u0435\u043d\u0438\u0435\u043c <em>globalThis <\/em>\u043c\u043e\u0436\u043d\u043e \u043f\u0435\u0440\u0435\u0441\u0442\u0430\u0442\u044c \u0434\u0443\u043c\u0430\u0442\u044c \u043e\u0431 \u043e\u043a\u0440\u0443\u0436\u0435\u043d\u0438\u0438 \u0438 \u043f\u043e\u043b\u0443\u0447\u0430\u0442\u044c \u0433\u043b\u043e\u0431\u0430\u043b\u044c\u043d\u044b\u0435 \u043e\u0431\u044a\u0435\u043a\u0442\u044b \u0443\u043d\u0438\u0444\u0438\u0446\u0438\u0440\u043e\u0432\u0430\u043d\u043e.<\/p>\n<p>  <\/p>\n<p><em>\u041f\u0440\u0438\u043c\u0435\u0440:<\/em><\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">globalThis.someFunction = () =&gt; 'hello'  console.log(globalThis.someFunction())<\/code><\/pre>\n<p>  <\/p>\n<h2><a href=\"https:\/\/github.com\/tc39\/proposal-promise-allSettled\">Promise.allSettled<\/a><\/h2>\n<p>  <\/p>\n<p>\u0414\u043e\u043f\u0443\u0441\u0442\u0438\u043c, \u0443 \u0432\u0430\u0441 \u0435\u0441\u0442\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043f\u0440\u043e\u043c\u0438\u0441\u043e\u0432, \u0438 \u0432\u044b \u0445\u043e\u0442\u0438\u0442\u0435 \u0447\u0442\u043e-\u0442\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u043f\u043e\u0441\u043b\u0435 \u0438\u0445 \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u0438\u044f (\u043d\u0435\u0432\u0430\u0436\u043d\u043e, \u0443\u0441\u043f\u0435\u0448\u043d\u043e\u0433\u043e \u0438\u043b\u0438 \u043d\u0435\u0442). <em>Promise.allSettled<\/em> \u043d\u0443\u0436\u0435\u043d \u0438\u043c\u0435\u043d\u043d\u043e \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e.<\/p>\n<p>  <\/p>\n<p><em>\u041f\u0440\u0438\u043c\u0435\u0440:<\/em><\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">const fulfilledPromise = Promise.resolve(\"success\"); const rejectedPromise = Promise.reject(\"error\") const promises = [fulfilledPromise, rejectedPromise];  Promise.allSettled(promises).   then((results) =&gt; results.forEach((result) =&gt; console.log(result)));<\/code><\/pre>\n<p>  <\/p>\n<p><em>\u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442:<\/em><\/p>\n<p>  <\/p>\n<div style=\"text-align:center;\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/155\/a78\/d67\/155a78d673de870c3ab4ab900cfdcf25.png\" width=\"896\" height=\"144\"><\/div>\n<p>  <\/p>\n<h2><a href=\"https:\/\/github.com\/tc39\/proposal-dynamic-import\">Dynamic Import<\/a><\/h2>\n<p>  <\/p>\n<p>\u0425\u043e\u0442\u0438\u0442\u0435 \u0437\u0430\u0433\u0440\u0443\u0437\u0438\u0442\u044c \u043c\u043e\u0434\u0443\u043b\u044c \u0432\u043e \u0432\u0440\u0435\u043c\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f, \u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u043e\u0433\u043e \u0443\u0441\u043b\u043e\u0432\u0438\u044f? \u0422\u0435\u043f\u0435\u0440\u044c \u044d\u0442\u043e \u043c\u043e\u0436\u043d\u043e \u0431\u0443\u0434\u0435\u0442 \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0431\u0435\u0437 \u0441\u0442\u043e\u0440\u043e\u043d\u043d\u0438\u0445 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a.<\/p>\n<p>  <\/p>\n<p>\u0414\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0432\u044b\u0437\u0432\u0430\u0442\u044c \u0444\u0443\u043d\u043a\u0446\u0438\u044e <em>import<\/em>, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0432\u0435\u0440\u043d\u0451\u0442 \u043f\u0440\u043e\u043c\u0438\u0441.<\/p>\n<p>  <\/p>\n<p><em>\u041f\u0440\u0438\u043c\u0435\u0440:<\/em><\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">import(\"some_module\")   .then(module =&gt; {     module.doSomething();   })   .catch(err =&gt; {     console.error(err.message);   });<\/code><\/pre>\n<p>  <\/p>\n<p>\u0412 \u043e\u0442\u043b\u0438\u0447\u0438\u0435 \u043e\u0442 \u0441\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0433\u043e \u0438\u043c\u043f\u043e\u0440\u0442\u0430, \u0433\u0434\u0435 \u043d\u0443\u0436\u043d\u043e \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0442\u044c \u0438\u043c\u044f \u043c\u043e\u0434\u0443\u043b\u044f \u044f\u0432\u043d\u043e, \u043f\u0440\u0438 \u0434\u0438\u043d\u0430\u043c\u0438\u0447\u0435\u0441\u043a\u043e\u043c \u0438\u043c\u043f\u043e\u0440\u0442\u0435 \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043f\u0435\u0440\u0435\u0434\u0430\u0442\u044c \u0432 \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u0448\u0430\u0431\u043b\u043e\u043d.<\/p>\n<p>  <\/p>\n<p><em>\u041f\u0440\u0438\u043c\u0435\u0440 \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u0448\u0430\u0431\u043b\u043e\u043d\u0430:<\/em><\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">import(`${some_module}.js`)   .then(module =&gt; {     module.doSomething();   })   .catch(err =&gt; {     console.error(err.message);   });<\/code><\/pre>\n<p>  <\/p>\n<h2><a href=\"https:\/\/github.com\/tc39\/proposal-nullish-coalescing\">Nullish coalescing<\/a><\/h2>\n<p>  <\/p>\n<p>\u041a\u043e\u0433\u0434\u0430 \u043d\u0443\u0436\u043d\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0430\u0442\u0440\u0438\u0431\u0443\u0442 \u0438\u043b\u0438 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e, \u0435\u0441\u043b\u0438 \u043e\u043d <em>null<\/em> \u0438\u043b\u0438 <em>undefined<\/em>, \u043c\u044b \u043e\u0431\u044b\u0447\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440 \u2018||\u2019.<\/p>\n<p>  <\/p>\n<p><em>\u0414\u043e Nullish coalescing:<\/em><\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">const response = someResponse.properties.mayBeUndefined || 'Response';<\/code><\/pre>\n<p>  <\/p>\n<p>\u041f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u044c\u0442\u0435, \u043e\u0434\u043d\u0430\u043a\u043e, \u0447\u0442\u043e \u0430\u0442\u0440\u0438\u0431\u0443\u0442 \u0438\u043c\u0435\u0435\u0442 \u00ab\u043b\u043e\u0436\u043d\u043e\u0435\u00bb \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435.<\/p>\n<p>  <\/p>\n<p><em>\u041f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u2018||\u2019:<\/em><\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">const someResponse = {properties: { mayBeUndefined: ''}} const response = someResponse.properties.mayBeUndefined || 'Response';  console.log(response)<\/code><\/pre>\n<p>  <\/p>\n<p><em>\u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442:<\/em><\/p>\n<p>  <\/p>\n<div style=\"text-align:center;\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/254\/f5e\/3c8\/254f5e3c8fd02963dc00ee32edf7b82a.png\" width=\"294\" height=\"80\"><\/div>\n<p>\u042d\u0442\u043e \u043d\u0435\u0436\u0435\u043b\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0435 \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u0435. \u0412 \u0434\u0430\u043d\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u0430, \u0430 \u043d\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e.  <\/p>\n<p>\u0421 <em>Nullish coalescing<\/em> \u044d\u0442\u043e\u0439 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b \u043d\u0435 \u0431\u0443\u0434\u0435\u0442. \u0417\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u0431\u0443\u0434\u0435\u0442 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0435\u043d\u043e \u0442\u043e\u043b\u044c\u043a\u043e \u0434\u043b\u044f \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u043e\u0432 <em>null<\/em> \u0438\u043b\u0438 <em>undefined<\/em>.<\/p>\n<p>  <\/p>\n<p><em>\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 Nullish coalescing:<\/em><\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">const someResponse = {properties: { mayBeUndefined: ''}} const response = someResponse.properties.mayBeUndefined ?? 'Response';  console.log(response)<\/code><\/pre>\n<p>  <\/p>\n<p><em>\u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442:<\/em>  <\/p>\n<div style=\"text-align:center;\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/4b7\/88d\/1ca\/4b788d1cac2f7cb836511c319e3dae58.png\" width=\"132\" height=\"72\"><\/div>\n<p>  <\/p>\n<h2><a href=\"https:\/\/github.com\/tc39\/proposal-optional-chaining\">Optional Chaining<\/a><\/h2>\n<p>  <\/p>\n<p>\u0427\u0442\u043e\u0431\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0434\u043e\u0441\u0442\u0443\u043f \u043a \u043f\u043e\u0434-\u0430\u0442\u0440\u0438\u0431\u0443\u0442\u0443, \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0443\u0431\u0435\u0434\u0438\u0442\u044c\u0441\u044f, \u0447\u0442\u043e \u0430\u0442\u0440\u0438\u0431\u0443\u0442 \u0432\u044b\u0448\u0435 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442. \u041f\u043e\u043a\u0430 \u0447\u0442\u043e \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u043e\u0432\u0430\u043d\u0438\u0435 \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0438\u0437 \u043d\u0430\u0434-\u0430\u0442\u0440\u0438\u0431\u0443\u0442\u043e\u0432 \u043d\u0443\u0436\u043d\u043e \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0442\u044c \u0432\u0440\u0443\u0447\u043d\u0443\u044e.<\/p>\n<p>  <\/p>\n<p><em>\u0414\u043e Optional Chaining:<\/em><\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">const someObj = {   property: 'prop',   otherProperty: {     name: 'prop2'   } };  const property = someObj.NotOtherProperty ? someObj.NotOtherProperty.name: undefined; console.log(property);<\/code><\/pre>\n<p>  <\/p>\n<p>\u0421 \u043f\u043e\u044f\u0432\u043b\u0435\u043d\u0438\u0435\u043c <em>Optional Chaining<\/em>, \u043c\u043e\u0436\u043d\u043e \u0431\u0443\u0434\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440 \u2018?.\u2019 \u0434\u043b\u044f \u043e\u043f\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u0434\u043e\u0441\u0442\u0443\u043f\u0430 \u043a \u043f\u043e\u0434-\u0430\u0442\u0440\u0438\u0431\u0443\u0442\u0430\u043c. \u041a\u043e\u0434 \u043d\u0438\u0436\u0435 \u044d\u043a\u0432\u0438\u0432\u0430\u043b\u0435\u043d\u0442\u0435\u043d \u043a\u043e\u0434\u0443 \u0432\u044b\u0448\u0435.<\/p>\n<p>  <\/p>\n<p><em>\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 Optional Chaining:<\/em><\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">const someObj = {   property: 'prop',   otherProperty: {     name: 'prop2'   } };  const property = someObj.NotOtherProperty?.name; console.log(property);<\/code><\/pre>\n<p>  <\/p>\n<p><em>Optional Chaining<\/em> \u0434\u0435\u043b\u0430\u0435\u0442 \u043a\u043e\u0434 \u0433\u043e\u0440\u0430\u0437\u0434\u043e \u0447\u0438\u0449\u0435, \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e, \u0435\u0441\u043b\u0438 \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u043e\u0432 \u0432 \u0441\u0442\u0440\u043e\u043a\u0435 \u043c\u043d\u043e\u0433\u043e.<\/p>\n<p>  <\/p>\n<h2>\u0417\u0430\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435<\/h2>\n<p>  <\/p>\n<p>\u0412\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u043f\u043e\u043f\u0440\u043e\u0431\u043e\u0432\u0430\u0442\u044c \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u043f\u0440\u0438\u043c\u0435\u0440\u044b \u0438\u0437 \u0441\u0442\u0430\u0442\u044c\u0438 \u0432 \u043a\u043e\u043d\u0441\u043e\u043b\u0438: <a href=\"https:\/\/kangax.github.io\/compat-table\/es2016plus\/\">\u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0438\u0437 \u043d\u0438\u0445<\/a> \u0443\u0436\u0435 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d\u044b \u0432 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0445 \u0432\u0435\u0440\u0441\u0438\u044f\u0445 \u0431\u0440\u0430\u0443\u0437\u0435\u0440\u043e\u0432, \u0434\u0440\u0443\u0433\u0438\u0435, \u0432\u0435\u0440\u043e\u044f\u0442\u043d\u043e, \u0431\u0443\u0434\u0443\u0442 \u0432\u043d\u0435\u0434\u0440\u0435\u043d\u044b \u043e\u0447\u0435\u043d\u044c \u0441\u043a\u043e\u0440\u043e. \u0422\u0430\u043a \u0438\u043b\u0438 \u0438\u043d\u0430\u0447\u0435, \u043a \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044f\u043c \u0438\u0437 \u0441\u0442\u0430\u0442\u044c\u0438 \u0443\u0436\u0435 \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u0447\u0438\u043d\u0430\u0442\u044c \u043e\u0442\u043d\u043e\u0441\u0438\u0442\u044c\u0441\u044f \u043a\u0430\u043a \u043a \u0447\u0430\u0441\u0442\u0438 \u044f\u0437\u044b\u043a\u0430 \u043e\u0431\u0440\u0430\u0437\u0446\u0430 2020 \u0433\u043e\u0434\u0430.<\/p>\n<\/div>\n<p>               <script class=\"js-mediator-script\">!function(e){function t(t,n){if(!(n in e)){for(var r,a=e.document,i=a.scripts,o=i.length;o--;)if(-1!==i[o].src.indexOf(t)){r=i[o];break}if(!r){r=a.createElement(\"script\"),r.type=\"text\/javascript\",r.async=!0,r.defer=!0,r.src=t,r.charset=\"UTF-8\";var d=function(){var e=a.getElementsByTagName(\"script\")[0];e.parentNode.insertBefore(r,e)};\"[object Opera]\"==e.opera?a.addEventListener?a.addEventListener(\"DOMContentLoaded\",d,!1):e.attachEvent(\"onload\",d):d() } } }t(\"\/\/mediator.mail.ru\/script\/2820404\/\",\"_mediator\")}(window);<\/script>      <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\/483118\/\"> https:\/\/habr.com\/ru\/post\/483118\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"\n<div class=\"post__text post__text-html js-mediator-article\" id=\"post-content-body\" data-io-article-url=\"https:\/\/habr.com\/ru\/post\/483118\/\">\n<p>\u041d\u0435\u0434\u0430\u0432\u043d\u043e \u043e\u043f\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u044b\u0439 \u0434\u043e\u0441\u0442\u0443\u043f \u043a \u0430\u0442\u0442\u0440\u0438\u0431\u0443\u0442\u0430\u043c (<em>Optional Chaining<\/em>) \u0438 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u0434\u043b\u044f \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u043e\u0432 (<em>Nullish Coalescing<\/em>) \u043f\u0435\u0440\u0435\u0448\u043b\u0438 \u043d\u0430 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0439, \u0447\u0435\u0442\u0432\u0451\u0440\u0442\u044b\u0439 \u044d\u0442\u0430\u043f \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430 TC39.<\/p>\n<p>  <\/p>\n<p>\u041d\u0430 \u043f\u0440\u0430\u043a\u0442\u0438\u043a\u0435 \u044d\u0442\u043e \u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442, \u0447\u0442\u043e \u044d\u0442\u0438 \u0438 \u0434\u0440\u0443\u0433\u0438\u0435 <a href=\"https:\/\/github.com\/tc39\/proposals\/blob\/master\/finished-proposals.md\">\u043d\u043e\u0432\u043e\u0432\u0432\u0435\u0434\u0435\u043d\u0438\u044f<\/a> \u0441\u0442\u0430\u043d\u0443\u0442 \u0447\u0430\u0441\u0442\u044c\u044e \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u0430 JavaScript \u0443\u0436\u0435 \u0432 \u044d\u0442\u043e\u043c, 2020 \u0433\u043e\u0434\u0443. \u0418\u0445 \u043c\u044b \u0438 \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0432 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435.<\/p>\n<p>  <\/p>\n<p><em>\u041e\u0442\u0441\u043b\u0435\u0436\u0438\u0432\u0430\u0442\u044c \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0443 \u0431\u0440\u0430\u0443\u0437\u0435\u0440\u0430\u043c\u0438 \u043c\u043e\u0436\u043d\u043e <a href=\"https:\/\/kangax.github.io\/compat-table\/es2016plus\/\">\u0437\u0434\u0435\u0441\u044c<\/a> (\u00ab2020 features\u00bb) \u2014 \u043f\u0440\u0438\u043c. \u043f\u0435\u0440\u0435\u0432.<\/em><\/p>\n<p>  <\/p>\n<p><em><\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/e8c\/27f\/6b0\/e8c27f6b0fcf596a06a31135d937c73e.png\"><\/div>\n<p><\/em><\/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-296880","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/296880","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=296880"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/296880\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=296880"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=296880"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=296880"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}