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

Revised Why local variables are called "let"

steve0greatness,
created on Saturday, 3 February 2024, 05:59:04 (1706939944), received on Monday, 6 May 2024, 02:55:37 (1714964137)
Author identity: Steve0Greatness <steve0greatnessiscool@gmail.com>

c69dc4f2aaf3bafb0de4e8e0246a0350d24c109d

blog-posts/whyLocalVarCallLet.md

@@ -1,5 +1,23 @@

                                
                                
                                
                            
                                
                                    
                                        
                                            
                                            ---
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            
                                            title: Why local variables are called "let"
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            
                                            date: 2022 Jan 10
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                        updated: 2024 Feb 2
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            
                                            ---
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                        <p>In JavaScript there are 3 different kinds of variables, global variables(using <span class="code">var</span>), constants(<span class="code">const</span>, and local variables(<span class="code">let</span>). All of the act allittle differently from eachother. Allow me to explain what they do.</p><p>Global variables, made using <span class="code">var</span>, are as they sound, global variables. Once defined, they can be used, edited, or redefind anywhere.</p><p>Constants, defined with <span class="code">const</span>, are constant, they cannot change, at all.</p><p>Local variables, defined with <span class="code">let</span>, are variables that can only be used in the place that it is defined, like a function, and it's children.</p>Now that we has that established, <em>let</em>'s talk about how local variables got their name.<p>Turns out "let" is a mathematical term. <span class="quote">The <b>"let" expression</b> may also be defined in mathematics, where it associates a Boolean condition with a restricted scope.</span> <a href="https://en.m.wikipedia.org/wiki/Let_expression" class="source">[source]</a>. It was first used in programming in early languages like Basic.</p>In case you're wondering, the main source is <a href="https://stackoverflow.com/a/37917071">this answer on Stack Overflow</a>.
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                        In JavaScript there are 3 different kinds of variables, global variables(using `var`), constants(`const`, and local variables`let`). All of the act a little differently from each other. Allow me to explain what they do.
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                        
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                        Global variables, made using `var`, are as they sound, global variables. Once defined, they can be used, edited, or redefined anywhere.
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                        
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                        Constants, defined with `const`, are constant, they cannot change, at all.
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                        
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                        Local variables, defined with `let`, are variables that can only be used in the place that it is defined, like a function, and it's children.
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                        
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                        Now that we has that established, *let*'s talk about how local variables got their name.
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                        
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                        Turns out "let" is a mathematical term.
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                        
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                        > The **"let" expression** may also be defined in mathematics, where it associates a Boolean condition with a restricted scope.
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                        > <cite>Quote from [Wikipedia "Let expression"](https://en.wikipedia.org/w/index.php?title=Let_expression&oldid=1187985658) as of <time>2024 Feb 2</time></cite>
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                        
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                        It was first used in programming in early languages like Basic.
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                        
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                        In case you're wondering, the main source is an answer on Stack Overflow: *"Why was the name 'let' chosen for block-scoped variable declarations in JavaScript?"*, answer by [exebook](https://stackoverflow.com/users/1968972), edited by [Pikamander2](https://stackoverflow.com/users/1741346); [link](https://stackoverflow.com/a/37917071).