<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Carol Gonzalez on Medium]]></title>
        <description><![CDATA[Stories by Carol Gonzalez on Medium]]></description>
        <link>https://medium.com/@carolgonzalez?source=rss-c1b18b98d302------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*miIgoCMOV95OSSi7o6pUjQ.jpeg</url>
            <title>Stories by Carol Gonzalez on Medium</title>
            <link>https://medium.com/@carolgonzalez?source=rss-c1b18b98d302------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 01 Dec 2026 23:30:47 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@carolgonzalez/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[ES 6 Let, Const and the Temporal Dead Zone]]></title>
            <link>https://medium.com/@carolgonzalez/es-6-let-const-and-the-temporal-dead-zone-d859a9f673df?source=rss-c1b18b98d302------2</link>
            <guid isPermaLink="false">https://medium.com/p/d859a9f673df</guid>
            <category><![CDATA[temporal-dead-zone]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[es6]]></category>
            <dc:creator><![CDATA[Carol Gonzalez]]></dc:creator>
            <pubDate>Fri, 01 Apr 2016 00:06:45 GMT</pubDate>
            <atom:updated>2016-04-01T00:30:58.993Z</atom:updated>
            <content:encoded><![CDATA[<h4>Au revoir <em>var </em>and hello <em>let</em> and <em>const</em></h4><p>As ES 6 rolls in we are faced with new concepts and while sometimes change is difficult to get used to I believe let and const will be gladly welcomed. These two new forms of variable declaration will make Javascript code much cleaner and less prone to getting the incorrect variable value.</p><h3>Let</h3><p>So what will let change?</p><p>The old “var=” model worked by allowing you to reference variables within the scope of their nearest parent function.</p><pre>(function cats(){<br>   console.log(name) // -&gt; <em>undefined</em><br>   var name = &#39;mittens&#39;;<br>   return name;<br>   console.log(name)// -&gt; <em>&#39;mittens&#39;</em><br>})();<br>//-&gt; &#39;<em>mittens&#39;</em></pre><pre>console.log(name)// -&gt; <em>Reference Error</em><br></pre><p>With <em>let</em> variable declaration will be attached to it’s nearest “block” and that’s also the only location where it can be referenced, so scoping is a lot tighter.</p><pre>function cats(name){<br>   console.log(breed); // -&gt; <em>Reference Error</em><br>   if(name === &#39;mittens&#39;){<br>      let breed = &#39;tabby&#39;;<br>      console.log(breed) // -&gt; <em>&#39;tabby&#39;</em>  <br>   }<br>   console.log(breed); // -&gt; <em>Reference Error</em><br>}<br>cats(&#39;mittens&#39;);</pre><p>With <em>let </em>the reference scope of our let variable <em>breed</em> is only available within the if conditional. Anything before or after its block is THE TEMPORAL DEAD ZONE!!!</p><p>Wait you say, what if sometimes you want a variable that is accessible anywhere in the scope of the function? Worry not, all you have to do is declare your variable at the top of you function</p><pre>function cats(name){<br>   let breed;<br>   if(name === &#39;mittens&#39;){<br>      breed = &#39;tabby&#39;;<br>      console.log(breed) // -&gt; <em>&#39;tabby&#39;</em>  <br>   }<br>   console.log(breed); // -&gt; &#39;<em>tabby&#39;</em><br>}<br>cats(&#39;mittens&#39;);</pre><p>But let’s go back to the temporal dead zone for a moment</p><h3>The Temporal Dead Zone</h3><p>The temporal dead zone semantics is a bit tricky. Here’s one more example so that we can talk through some of the things that happen in TDZ</p><pre>function(){<br>   console.log(x); // -&gt; <em>Reference Error</em><br>   let x = 1;<br>}</pre><p>as we can see logging <em>x</em> before it’s been declared throws a <em>Reference Error</em> and we might be inclined to think that this is because let doesn’t allow hoisting to happen, but actually it does.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/591/1*L-siN84A2uRdWIxK4QGSiQ.png" /></figure><p>Hoisting does happen to x, so why the <em>Reference Error</em>?</p><p>This is because <strong>declarations do hoist</strong>, but <strong>they throw errors when accessed before being initialized</strong></p><p>Moving on</p><h3>Const</h3><p>So what does <em>Const</em> do for us you ask???</p><p>Well let’s clear up something first, const means constant reference to a value and NOT constant value.</p><p>So what does that mean. It mean that when you use const the <strong>pointer</strong> that the variable name is using to point <strong>cannot change</strong>, but the <strong>value</strong> it is pointing to<strong> can change</strong></p><p>This might be better explained with an example. Here our pointer is ‘names’ and the value it is pointing to is an empty array([])</p><pre>const names = [];<br>names.push( “Jordan” );<br>console.log( names );</pre><p>The value can change. We are pushing Jordan into the array.</p><p>But names cannot be reassigned to point to something else.</p><p>Neat right!</p><p>One more thing to remember const and let follow the same scoping rules so if you log a const variable before it has been defined it will Reference Error</p><p>Well now that you’re equipped I hope you have fun exploring all the quirks and joys of const and let!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d859a9f673df" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The Bridges That Are Express Middleware]]></title>
            <link>https://medium.com/@carolgonzalez/the-bridges-that-are-express-middleware-7f135bd57e45?source=rss-c1b18b98d302------2</link>
            <guid isPermaLink="false">https://medium.com/p/7f135bd57e45</guid>
            <category><![CDATA[express]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[middleware]]></category>
            <dc:creator><![CDATA[Carol Gonzalez]]></dc:creator>
            <pubDate>Wed, 24 Feb 2016 01:34:29 GMT</pubDate>
            <atom:updated>2016-02-24T01:34:29.565Z</atom:updated>
            <content:encoded><![CDATA[<p>Middleware the intricately spun web of functions activated by routes/paths in your server, and chained to each other by the calling of next().</p><p>If you’re new to server routing and have always wondered what happens next after you type a url with a path this is for you.</p><h3>So what is middleware?</h3><p><strong><em>Middleware</em></strong> functions are functions that have access to the <a href="http://expressjs.com/en/4x/api.html#req">request object</a> (req), the <a href="http://expressjs.com/en/4x/api.html#res">response object</a> (res), and the next middleware function in the application’s request-response cycle.</p><pre>app.get(&#39;/login&#39;, Middleware, function (req, res) {<br>  res.send(&#39;index.html&#39;);<br>});</pre><p>As the description in expressjs.com puts it-</p><p>Middleware functions can perform the following tasks:</p><ul><li>Execute any code.</li><li>Make changes to the request and the response objects.</li><li>End the request-response cycle.</li><li>Call the next middleware function in the stack.</li></ul><p>If the current middleware function does not end the request-response cycle, it must call next() to pass control to the next middleware function. Otherwise, the request will be left hanging.</p><h3>So How to Construct a Middleware Function?</h3><p>Middleware has any functionality you want you can do something as useful as giving your user a cookie before you res.send them the index.html or it can do something as useless as adding 2+2 (which you probably won’t be doing ;) )</p><p>Ultimately middleware is an intermediate step before you serve up a file.</p><p>Middleware also allows you to keep your code modularized instead of having to put all your login in the function that follows a path</p><p>Let’s use the example that we showed above,</p><pre>app.get(&#39;/login&#39;, Middleware, function (req, res) {<br>  res.send(&#39;index.html&#39;);<br>});</pre><p>it looks clean and the middleware function between the path and the anonymous function lives happily in some other doc.</p><p>let’s see a mock middleware function:</p><pre>function Middleware (req, res, next){<br> console.log(req);<br> res.name = &quot;username&quot;;<br> next();</pre><pre>}</pre><p>Looks pretty normal right?</p><p>The only special things about middleware are you it takes in req, res and next as arguments and it can do things like add key values to the response object or even look at the request object.</p><p>One important detail in all middleware is to always call the next( ); function so that it goes on the function available.</p><p>If the middleware function is that last stop on the train though don’t forget to <strong>End</strong> the request-response cycle with a res.end( );</p><p>Like this:</p><pre>function Middleware (req, res, next){<br> console.log(req);<br> res.name = &quot;username&quot;;<br> res.end();</pre><pre>}</pre><p>Have fun spinning the webs of middleware and hopefully you don’t get too tangled along the way!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7f135bd57e45" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[NODE_ENV]]></title>
            <link>https://medium.com/@carolgonzalez/node-env-5aa7bbf7ab4?source=rss-c1b18b98d302------2</link>
            <guid isPermaLink="false">https://medium.com/p/5aa7bbf7ab4</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[node-env]]></category>
            <category><![CDATA[expressjs]]></category>
            <dc:creator><![CDATA[Carol Gonzalez]]></dc:creator>
            <pubDate>Wed, 20 Jan 2016 00:49:54 GMT</pubDate>
            <atom:updated>2016-01-20T01:01:55.164Z</atom:updated>
            <content:encoded><![CDATA[<p>Picture this, your project is in development mode with debugging and logging code. It will go into production and at some point in the future it will be iterated upon and come back to development.</p><p>You could remove your debugging and logging code and add it on later when needed OR you could set up your node_env variable to switch between the production and development environment of the project.</p><p>This is the purpose of setting up your node_env.</p><pre>export NODE_ENV = development;</pre><p>NODE_ENV was made popular by express and is often used to check the environment under which your project is currently under and run/do different things depending on whether it’s set to production or not. This makes NODE_ENV and <a href="https://en.wikipedia.org/wiki/Environment_variable">environment variable</a>.</p><p>So how do you check it once you’ve set it?</p><p>You can use the following code to access the environment variable yourself so that you can perform your own checks and logic:</p><pre>var environment = process.env.NODE_ENV</pre><p>Or by using Express:</p><pre>app.get(‘env’) </pre><p>*if you try to console.log(node_env) before you set it you’ll see that you get an undefined. So don’t forget to set it</p><p>Convention has dictated that there are only two values you should use for NODE_ENV, either production or development, all lowercase. There’s nothing stopping you adding more values.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5aa7bbf7ab4" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How To Properly Indent In Javascript]]></title>
            <link>https://medium.com/@carolgonzalez/how-to-properly-indent-in-javascript-b2c432dcda11?source=rss-c1b18b98d302------2</link>
            <guid isPermaLink="false">https://medium.com/p/b2c432dcda11</guid>
            <dc:creator><![CDATA[Carol Gonzalez]]></dc:creator>
            <pubDate>Tue, 16 Jun 2015 00:56:39 GMT</pubDate>
            <atom:updated>2015-06-16T01:31:46.632Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/601/1*6tqmy_EGxIbkJwAN3LEF6A.png" /><figcaption>The Code of Hell!</figcaption></figure><p>Saying please and thank you and washing your hands before eating are some of the golden rules of life, and here’s one more:</p><p>When coding, check your indentation. A.K.A (Indent yo’ self before you wreck yo’ self).</p><p><strong>WHY INDENT?</strong></p><p>Indentation is a way of keeping your code readable both for yourself and others. It also makes it easier to debug and to notice small syntax errors like a missing semi-colon or a missing closing curly brace.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/475/1*XiJv3DSwvFdIhx5rjCxiGA.jpeg" /><figcaption>Don’t be this guy</figcaption></figure><p><strong>HOW DO WE INDENT?</strong></p><blockquote><strong>Indentation always starts after you’ve opened a function or a loop!</strong></blockquote><p>Disclaimer: These are some rules to help but these aren’t the only ones and if you are working with a style-sheet it might have some specific ways of arranging your code.</p><p>WRONG WAY:</p><p>Lines aren’t indented and you can’t tell one function from the other.</p><pre>var Greeting = function (phrase){<br>var wholePhrase = phrase + “John”;<br>function(){<br>return wholePhrase;<br>}<br>};</pre><p>WRONG WAY:</p><p>Everything is “packed” together.</p><pre>var Greeting = function (phrase){var wholePhrase = phrase + “John”;return wholePhrase;};</pre><p>RIGHT WAY:</p><ol><li>Properly scaffolded and you can tell where one function ends and another begins</li><li>You can clearly see that:</li></ol><ul><li><em>our loop is inside </em>of our Greeting function</li><li><em>our var “wholePhrase is inside </em>our loop and <em>where the ending curly brace for our loop is</em></li><li><em>our anonymous function is inside</em> our Greeting function but NOT inside of our loop because it’s not as indented as our var “wholePhrase”</li><li>that our <em>return statement in inside</em> our anonymous function and <em>where the closing curly brace</em> to our anonymous function is!</li></ul><pre>var morningPhrases = [&#39;Guten Morgen&#39;, &#39;Buenos Dias&#39;, &#39;Good Morning&#39;];</pre><pre>var Greeting = function(phraseArray){<br>    for (var i=0; i&lt;phrasesArray.length; i++){<br>        var wholePhrase = phrasesArray[i] + “John”;<br>    }    <br>    function() {<br>        return wholePhrase;<br>    }</pre><pre>};<br>Greeting(morningPhrases);</pre><p>One more thing, usually the indent tab is sufficient after you write code that follows the opening of a function, but if it doesn’t usually 4 spaces are a good measure of one tab click.</p><p>Now venture out into the land of stylesheets but don’t forget the golden rule. Always indent! and indentation begins after the opening of a function, or a loop.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b2c432dcda11" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>