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
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -101,4 +101,6 @@ dist
.dynamodb/

# TernJS port file
.tern-port
.tern-port

.idea
10 changes: 10 additions & 0 deletions .idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/article-markup.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

29 changes: 28 additions & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,33 @@
<link rel="stylesheet" href="styles.css">
</head>
<body>
<!--Статью верстать тут-->
<h1 class ="title-1"> Замыкания в JavaScript для начинающих </h1>
<p class="paragraf-1">
Замыкания — это одна из фундаментальных концепций JavaScript, вызывающая сложности у многих новичков, знать и понимать которую должен каждый JS-программист. Хорошо разобравшись с замыканиями, вы сможете писать более качественный, эффективный и чистый код. А это, в свою очередь, будет способствовать вашему профессиональному росту.<br><br>
Материал, перевод которого мы публикуем сегодня, посвящён рассказу о внутренних механизмах замыканий и о том, как они работают в JavaScript-программах.
</p>

<div class="par2">
<b>Что такое замыкание?</b>
<p>Замыкание — это функция, у которой есть доступ к области видимости, сформированной внешней по отношению к ней
функции даже после того, как эта внешняя функция завершила работу. Это значит, что в замыкании могут храниться
переменные, объявленные во внешней функции и переданные ей аргументы. Прежде чем мы перейдём, собственно, к
замыканиям, разберёмся с понятием «лексическое окружение».
</p>
</div>

<div class="p-title-3"><p>Что такое лексическое окружение?</p></div>
<div class="text-block-3">
<p>Понятие «лексическое окружение» или «статическое окружение» в JavaScript относится к возможности доступа к переменным, функциям и объектам на основе их физического расположения в исходном коде. <br> Рассмотрим пример:</p>
</div>

<img src="responsive-design/2744EFD6-B878-4DCB-B0D5-526F1B233733/CA501510-E978-4377-9076-8F392B899C1B@0.5x.png" alt="code img" id="pic-1">

<div class="text-block-4"><p>Здесь у функции <code>inner()</code> есть доступ к переменным, объявленным в её собственной области видимости, в области видимости функции <code>outer()</code> и в глобальной области видимости. Функция <code>outer()</code> имеет доступ к переменным, объявленным в её собственной области видимости и в глобальной области видимости. <br> <br>
Цепочка областей видимости вышеприведённого кода будет выглядеть так:</p></div>

<img src="responsive-design/2744EFD6-B878-4DCB-B0D5-526F1B233733/848B0BFD-C857-4F1E-93BF-3822E0A81A7E@3x.png" alt="code img" id="pic-2">

<div class="text-block-5"><p>Обратите внимание на то, что функция <code>inner()</code> окружена лексическим окружением функции <code>outer()</code>, которая, в свою очередь, окружена глобальной областью видимости. Именно поэтому функция <code>inner()</code> может получить доступ к переменным, объявленным в функции <code>outer()</code> и в глобальной области видимости.</p></div>
</body>
</html>
247 changes: 244 additions & 3 deletions styles.css
Original file line number Diff line number Diff line change
@@ -1,8 +1,249 @@
/* Тут пиши основные стили */
body {
position: relative;
margin: 0;
padding: 40px 20px;
min-height: 100vh;
}

.title-1 {
width: 700px;
height: 88px;
font-size: 42px;
color:rgba(0,0,0,0.84);
text-align: left;
line-height: 44px;
margin-right: 362px;
margin-left: 362px;
margin-top: 55px;
font-family: "Lucida Grande", "Lucida Sans Unicode", "Lucida Sans", Geneva, Arial, sans-serif
}

h1.title-1{
margin-block-start: 0px;
}

.paragraf-1 {
width: 700px;
margin-right: 362px;
margin-left: 362px;
margin-top: 10px;
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;
margin-block-end: 0px;
}

.par2{
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;
width:700px;
margin-right: 362px;
margin-left: 362px;
margin-top: 55px;
}

.par2 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;
width:700px;
margin-bottom: 56px;
margin-top: 10px;
}

.text-block-3 {

width: 700px;
height: 132px;

font-family: Georgia, Cambria, "Times New Roman", Times, serif;
font-size: 21px;
line-height: 33px;


color: rgba(0, 0, 0, 0.84);

text-align: left;


margin-left: 362px;
margin-right: 362px;
}


.p-title-3 {
width: 700px;
height: 39px;

margin-top: 10px;
margin-left: 364px;
margin-right: 364px;

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

#pic-1 {
width: 700px;
height: 727px;

margin-left: 362px;
margin-right: 362px;
}


.text-block-4 {
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;

width: 700px;
height: 267px;

margin-left: 362px;
margin-right: 362px;
}

#pic-2 {
width: 700px;
height: 923px;

margin-left: 362px;
margin-right: 362px;
margin-top: 41px;
}

.text-block-5 {
font-family:Georgia;
font-size:21px;
color:rgba(0,0,0,0.84);
text-align:left;
line-height:33px;
width: 700px;
height: 165px;

margin-left: 362px;
margin-right: 362px;
margin-bottom: 92px;

}

code {
background-color: lightgray;
border-radius: 20%;
}

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

.title-1 {
width: 100%;
height: auto;
font-size: 28px;
line-height: 36px;
margin: 20px 0 0 0;
padding: 0;
text-align: left;
}

.paragraf-1 {
width: 100%;
height: auto;
font-size: 16px;
line-height: 26px;
margin: 15px 0 0 0;
padding: 0;
}

.par2 {
width: 100%;
font-size: 24px;
line-height: 32px;
margin: 20px 0 0 0;
padding: 0;
}

.par2 p {
width: 100%;
height: auto;
font-size: 16px;
line-height: 26px;
margin: 10px 0 0 0;
padding: 0;
}

.text-block-3 {
width: 100%;
height: auto;
font-size: 16px;
line-height: 26px;
margin: 15px 0 0 0;
padding: 0;
}

.p-title-3 {
width: 100%;
height: auto;
font-size: 24px;
line-height: 32px;
margin: 20px 0 0 0;
padding: 0;
text-align: left;
}

#pic-1 {
width: 100%;
height: auto;
margin: 15px 0 0 0;
padding: 0;
}

.text-block-4 {
width: 100%;
height: auto;
font-size: 16px;
line-height: 26px;
margin: 15px 0 0 0;
padding: 0;
}

#pic-2 {
width: 100%;
height: auto;
margin: 15px 0 0 0;
padding: 0;
}

.text-block-5 {
width: 100%;
height: auto;
font-size: 16px;
line-height: 26px;
margin: 15px 0 0 0;
padding: 0;
}

code {
display: inline-block;
max-width: 100%;
overflow-x: auto;
white-space: pre-wrap;
word-wrap: break-word;
}
}