A mirror of my website's source code.

By using this site, you agree to have cookies stored on your device, strictly for functional purposes, such as storing your session and preferences.

Dismiss

 whyLocalVarCallLet.html

View raw Download
text/html • 5.95 kiB
HTML document, ASCII text, with very long lines (383)
        
            
1
<!DOCTYPE html>
2
<html lang="en-us" prefix="og: https://ogp.me/ns# article: http://ogp.me/ns/article# profile: https://ogp.me/ns/profile#">
3
4
<head>
5
6
7
<meta charset="UTF-8" />
8
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
9
<title>Why local variables are called "let" - S0G</title>
10
<link rel="stylesheet" href="/src/global.css" />
11
<meta property="og:locale" content="en_US" />
12
<meta property="og:site_name" content="Steve0Greatness" />
13
<meta property="og:image" content="/OG-Image.png" />
14
15
<link rel="stylesheet" href="/src/code-blocks.css" />
16
<link rel="stylesheet" href="/src/blog.css" />
17
<link rel="alternate" href="/blog/whyLocalVarCallLet.txt" type="text/plain" title="Post source" />
18
<meta property="og:title" content="Why local variables are called "let"" />
19
<meta property="og:type" content="article" />
20
<meta property="article:published_time" content="2022-01-10T00:00:00Z" />
21
<meta property="article:author" content"https://steve0greatness.github.io" />
22
<meta property="article:modified_time" content="2024-02-02T00:00:00Z" />
23
<meta property="profile:first_name" content="Steve0Greatness" />
24
<meta property="profile:username" content="Steve0Greatness" />
25
<meta property="profile:gender" content="male" />
26
<meta property="og:url" content="https://steve0greatness.github.io/blog/whyLocalVarCallLet.html" />
27
28
</head>
29
30
<body>
31
<header>
32
<h2><a href="/"><img src="/SteveLogo.webp" height="35" width="215" alt="Steve0Greatness" /></a></h2>
33
<nav>
34
<a href="/blog">Blog</a>
35
<a href="/list/link-tree.html">Link Tree</a>
36
</nav>
37
</header>
38
39
<nav aria-label="breadcrumbs" aria-roledescription="Site breadcrumb">
40
<ol class="breadcrumbs">
41
42
<li>
43
<a href="/">Index</a>
44
</li>
45
46
<li >
47
<a
48
49
href="/blog"
50
>Blog Index</a>
51
</li>
52
53
<li >
54
<a
55
aria-current="location"
56
href="/blog/whyLocalVarCallLet.html"
57
>Why local variables are called "let"</a>
58
</li>
59
60
61
</ol>
62
</nav>
63
<main>
64
<h1>Why local variables are called "let"</h1>
65
<article>
66
<header>
67
<div role="toolbar" class="toolbar">
68
<strong>Share</strong>
69
<a href="https://toot.kytta.dev/?text=Take a look at this article by @S0G@mastodon.social: https://steve0greatness.github.io/blog/whyLocalVarCallLet.html" title="Share to Mastodon">
70
<img src="/toot-kytta-dev-icon.png" width="16" height="16" aria-hidden="true" title="Share to Mastodon" />
71
</a>
72
<a href="/blog/whyLocalVarCallLet.html" title="Direct link">
73
<img src="/link-icon.png" width="16" height="16" aria-hidden="true" title="Direct link" />
74
</a>
75
<a href="/blog/whyLocalVarCallLet.txt" title="Markdown source">
76
<img src="/md-src.png" width="16" height="16" aria-hidden="true" />
77
</a>
78
</div>
79
<div class="time-stamps">
80
<time datetime="2022-01-10T00:00:00-08:00">2022 Jan 10 PST</time>
81
- <span aria-hidden="true" style="font-style:italic">Revision as of: </span> <time datetime="2024-02-02T00:00:00-08:00" aria-label="Revision">2024 Feb 2 PST</time>
82
83
</div>
84
</header>
85
<p>In JavaScript there are 3 different kinds of variables, global variables(using <code>var</code>), constants(<code>const</code>, and local variables<code>let</code>). All of the act a little differently from each other. Allow me to explain what they do.</p>
86
87
<p>Global variables, made using <code>var</code>, are as they sound, global variables. Once defined, they can be used, edited, or redefined anywhere.</p>
88
89
<p>Constants, defined with <code>const</code>, are constant, they cannot change, at all.</p>
90
91
<p>Local variables, defined with <code>let</code>, are variables that can only be used in the place that it is defined, like a function, and it's children.</p>
92
93
<p>Now that we has that established, <em>let</em>'s talk about how local variables got their name.</p>
94
95
<p>Turns out "let" is a mathematical term.</p>
96
97
<blockquote>
98
<p>The <strong>"let" expression</strong> may also be defined in mathematics, where it associates a Boolean condition with a restricted scope.
99
<cite>Quote from <a href="https://en.wikipedia.org/w/index.php?title=Let_expression&oldid=1187985658">Wikipedia "Let expression"</a> as of <time>2024 Feb 2</time></cite></p>
100
</blockquote>
101
102
<p>It was first used in programming in early languages like Basic.</p>
103
104
<p>In case you're wondering, the main source is an answer on Stack Overflow: <em>"Why was the name 'let' chosen for block-scoped variable declarations in JavaScript?"</em>, answer by <a href="https://stackoverflow.com/users/1968972">exebook</a>, edited by <a href="https://stackoverflow.com/users/1741346">Pikamander2</a>; <a href="https://stackoverflow.com/a/37917071">link</a>.</p>
105
106
</article>
107
</main>
108
<footer>
109
<div class="footer-link-list-holder" role="group">
110
<span aria-hidden="true" id="footer-label-site-details" class="footer-link-list-label">Site Meta</span>
111
<ol class="footer-link-list" aria-labelledby="footer-label-site-details">
112
<li><a href="/list/website-sources-mirrors.html">Source Code and Mirrors</a></li>
113
<li><a href="https://steve0greatness.github.io/extras">Extras</a></li>
114
</ol>
115
</div>
116
<div class="footer-link-list-holder" role="group">
117
<span aria-hidden="true" id="footer-label-social-accounts" class="footer-link-list-label">Social Accounts</span>
118
<ol class="footer-link-list" aria-labelledby="footer-label-social-accounts">
119
<li><a href="https://mastodon.social/@S0G" rel="me">Mastodon</a></li>
120
<li><a href="https://youtube.com/@s0g">YouTube</a></li>
121
<li><a href="/list/link-tree.html">More...</a></li>
122
</ol>
123
</div>
124
</footer>
125
</body>
126
127
</html>