Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added images/artboard.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/logo@0.5x.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/logo@1x.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/logo@2x.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/logo@3x.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/snippet1@0.5x.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/snippet1@1x.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/snippet1@2x.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/snippet1@3x.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/snippet2@0.5x.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/snippet2@1x.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/snippet2@2x.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/snippet2@3x.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
28 changes: 27 additions & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,34 @@
<meta charset="UTF-8">
<title>Практика верстки</title>
<link rel="stylesheet" href="styles.css">
<meta name="viewport" content="width=device-width, initial-scale=1">
</head>
<body>
<!--Статью верстать тут-->
<img class="logo" src="images/logo@1x.png" alt="Logo">
<nav>
<ul>
<li><a>Обо мне</a></li>
<li><a>Проекты</a></li>
<li><a>Портфолио</a></li>
<li><a href="index.html">Блог</a></li>
<li><a>Контакты</a></li>
</ul>
</nav>
<div class="page-content">
<h1>Замыкания в JavaScript для начинающих</h1>
<p>Замыкания — это одна из фундаментальных концепций JavaScript, вызывающая сложности у многих новичков, знать и понимать которую должен каждый JS-программист. Хорошо разобравшись с замыканиями, вы сможете писать более качественный, эффективный и чистый код. А это, в свою очередь, будет способствовать вашему профессиональному росту.

Материал, перевод которого мы публикуем сегодня, посвящён рассказу о внутренних механизмах замыканий и о том, как они работают в JavaScript-программах.</p>
<!-- TODO возможно сделать как два <p> -->
<h2>Что такое замыкание?</h2>
<p>Замыкание — это функция, у которой есть доступ к области видимости, сформированной внешней по отношению к ней функции даже после того, как эта внешняя функция завершила работу. Это значит, что в замыкании могут храниться переменные, объявленные во внешней функции и переданные ей аргументы. Прежде чем мы перейдём, собственно, к замыканиям, разберёмся с понятием «лексическое окружение».</p>

<h2>Что такое лексическое окружение?</h2>
<p>Понятие «лексическое окружение» или «статическое окружение» в JavaScript относится к возможности доступа к переменным, функциям и объектам на основе их физического расположения в исходном коде. Рассмотрим пример:</p>
<img src="images/snippet1@1x.png" alt="Code snippet">
<p>Здесь у функции <code>inner()</code> есть доступ к переменным, объявленным в её собственной области видимости, в области видимости функции <code>outer()</code> и в глобальной области видимости. Функция <code>outer()</code> имеет доступ к переменным, объявленным в её собственной области видимости и в глобальной области видимости.</p>
<img src="images/snippet2@1x.png" alt="Code snippet">
<p>Обратите внимание на то, что функция <code>inner()</code> окружена лексическим окружением функции <code>outer()</code>, которая, в свою очередь, окружена глобальной областью видимости. Именно поэтому функция <code>inner()</code> может получить доступ к переменным, объявленным в функции <code>outer()</code> и в глобальной области видимости.</p>
</div>
</body>
</html>
134 changes: 131 additions & 3 deletions styles.css
Original file line number Diff line number Diff line change
@@ -1,8 +1,136 @@
/* Тут пиши основные стили */
.page-content {
width: 700px;
margin: auto;
}

body {
margin: 0;
}

.logo {
margin: 10px 38px;
}

nav {
background-color: #faf9f8;
padding: 24px 38px;
margin: 0;
border-bottom: 1px solid #c2c2c2;
border-top: 1px solid #c2c2c2;
}

nav li {
list-style: none;
display: inline;
cursor: grab;
}

nav ul {
margin: 0;
padding: 0;
}

a {
font-family: "Lucida Grande", "Lucida Sans Unicode", "Lucida Sans", Geneva, Arial, sans-serif;
font-size:24px;
color:#333333;
text-align:left;
line-height:36px;
margin-right: 30px;
cursor: grab;
text-decoration: none;
}

a:visited {
color: #d0021b;
text-decoration: none;
}

a:hover {
text-decoration: underline;
}

h1 {
font-family: "Lucida Grande", "Lucida Sans Unicode", "Lucida Sans", Geneva, Arial, sans-serif;
font-size:42px;
color:rgba(0,0,0,0.84);
text-align:left;
line-height:44px;
}
#Logo{
align-content: start;
margin-top: 10px;
margin-left: 38px;
margin-bottom: 10px;
}

h2 {
font-family: "Lucida Grande", "Lucida Sans Unicode", "Lucida Sans", Geneva, Arial, sans-serif;
font-size:34px;
color:rgba(0,0,0,0.84);
text-align:left;
line-height:39px;
}

p {
font-family: Georgia, Cambria, "Times New Roman", Times, serif;
font-size:21px;
color:rgba(0,0,0,0.84);
text-align:left;
line-height:33px;
}

code {
font-family: "Courier New", monospace;
background-color: #f2f2f2;
}




@media (max-width: 800px) {
/* Тут пиши стили для мобилки.
Стили применятся только когда страничка будет ≤800px шириной
*/
.page-content {
margin: auto 20px;
width: auto;
}

body {
width: 100%;
}

img {
width: 100%;
}

.logo {
width: 101px;
height: 64px;
margin: 10px 20px;
}

nav {
padding: 20px 20px;
}

nav li {
display: block;
margin: 0 0 10px 0;
}

a {
font-size: 20px;
}

h1 {
font-size: 26px;
}

h2 {
font-size: 22px;
}

p {
font-size: 18px;
}
}