<?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 Daniel Park on Medium]]></title>
        <description><![CDATA[Stories by Daniel Park on Medium]]></description>
        <link>https://medium.com/@dpark?source=rss-411985dba33------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*UjmKCoRg43xNvyoSgApUyA.jpeg</url>
            <title>Stories by Daniel Park on Medium</title>
            <link>https://medium.com/@dpark?source=rss-411985dba33------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Thu, 19 Nov 2026 12:03:38 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@dpark/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[UI testing with Puppeteer and Mocha]]></title>
            <link>https://medium.com/@dpark/ui-testing-with-puppeteer-and-mocha-8a5c6feb3407?source=rss-411985dba33------2</link>
            <guid isPermaLink="false">https://medium.com/p/8a5c6feb3407</guid>
            <category><![CDATA[mocha]]></category>
            <category><![CDATA[puppeteer]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[ui-testing]]></category>
            <category><![CDATA[headless-chrome]]></category>
            <dc:creator><![CDATA[Daniel Park]]></dc:creator>
            <pubDate>Fri, 16 Mar 2018 02:35:04 GMT</pubDate>
            <atom:updated>2018-03-16T02:35:04.733Z</atom:updated>
            <content:encoded><![CDATA[<h3><strong>Setup</strong></h3><ul><li>To install, run npm install puppeteer</li><li><strong>Caution: Puppeteer requires at least Node v6.4.0, but the examples below use async/await which is only supported in Node v7.6.0 or greater.</strong></li><li>This will also downloads the latest version of Chromium to ensure that it works with the API and not worry about any environment variables. To bypass this download, <a href="https://github.com/GoogleChrome/puppeteer/blob/master/docs/api.md#environment-variables">look here</a>.</li><li>Create the file index.js in the test folder. We will eventually use this same file to write tests with Mocha.</li><li>In package.json, create a test command:</li></ul><pre>&quot;scripts&quot;: { <br>  &quot;test&quot;: &quot;node ./lib/js/tests/index2.js&quot; <br>},</pre><h3>Write puppeteer actions</h3><h4>index.js</h4><p>For staters, we need to:</p><pre>const puppeteer = require( &#39;puppeteer&#39; );<br>const devices = require(&#39;puppeteer/DeviceDescriptors&#39;);</pre><ul><li>The second require is only if you want to emulate a different device such as the iPhone 6. You can check out the list in that file.</li><li>By default, the viewport is set to 800 x 600 pixels.</li><li>The first example in <a href="https://developers.google.com/web/tools/puppeteer/get-started">Google’s documentation</a> shows how to create a screenshot of a page.</li></ul><pre>(async () =&gt; {<br>  const browser = await puppeteer.launch();<br>  const page = await browser.newPage();<br>  await page.goto(&#39;https://example.com&#39;);<br>  await page.screenshot({path: &#39;example.png&#39;});<br>  await browser.close();<br>})();</pre><ul><li>I highly recommend that you put an option to the .goto() method in order to have it wait until the page is fully loaded. There are four options: load, domcontentloaded, networkidle0, networkidle2.</li><li>load is the default option. This waits until the load event is fired which is not the quickest but <strong>Puppeteer will blow if it exceeds 30 seconds</strong>.</li></ul><pre>await page.goto(&#39;https://example.com&#39;, {waitUntil: &#39;domcontentloaded&#39;});</pre><ul><li>Another option is to disable the timeout to 0.</li></ul><pre>await page.goto(&#39;https://example.com&#39;, {timeout: 0, waitUntil: &#39;domcontentloaded&#39;});</pre><h4>Browser Options</h4><ul><li>You can set the default headless mode to false and the browser will launch on the UI and you be able see the whole process in action.</li></ul><pre>const browser = await puppeteer.launch( {headless: false} );</pre><ul><li>You can also slows down the whole operation.</li></ul><pre>const browser = await puppeteer.launch( {slowMo: 250} );</pre><ul><li>You can launch the browser with the DevTools panel open.</li></ul><pre>const browser = await puppeteer.launch( {devtools: false} );</pre><h4>Viewport/Device options</h4><ul><li>Setting the viewport</li></ul><pre>await page.setViewport( { width: 1280, height: 800} );</pre><ul><li>Emulating a device</li></ul><pre>await page.emulate( devices[ &#39;iPhone 6 Plus&#39; ] );</pre><h4>Clicking on an element</h4><pre>await page.$eval( &#39;.nav_reveal&#39;, button =&gt; {<br>  button.click();<br>});</pre><h4>Running Puppeteer</h4><ul><li>Run node ./lib/js/tests/index2.js or if the test command in the package.json is setup, you can run just npm run test</li></ul><h3>Adding Mocha</h3><ul><li>Change the command test to:</li></ul><pre>&quot;scripts&quot;: { <br>  &quot;test&quot;: &quot;./node_modules/mocha/bin/mocha lib/js/tests/index.js&quot;<br>},</pre><ul><li>Make sure to add the assertion library of your choice. I’m using Chai’s (TDD) assert library.</li></ul><pre>const puppeteer = require( &#39;puppeteer&#39; );<br>const devices = require(&#39;puppeteer/DeviceDescriptors&#39;);</pre><pre>const assert = require( &#39;chai&#39; ).assert;</pre><ul><li>To make sure that Mocha is working</li></ul><pre>describe( &#39;test&#39;, () =&gt; {<br>  it( &#39;test1&#39;, () =&gt; {<br>    const result = true;<br>    assert.strictEqual( result, true );<br>  });<br>});</pre><ul><li>Run npm run test</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/215/1*woYIpICqmWy5YrTT-rlG5Q.png" /></figure><h4>Testing with Puppeteer + Mocha</h4><ul><li>Make sure that we are using async functions.</li><li>Declare the browser and page variables outside the it() functions.</li></ul><pre>describe( &#39;Test Website&#39;, async () =&gt; {<br>  it( &#39;Browser Opens Successfully&#39;, async () =&gt; {<br>    browser = await puppeteer.launch(opts);<br>  });</pre><pre>  it( &#39;Page Open Successfully&#39;, async () =&gt; {<br>    page = await browser.newPage();<br>  });</pre><pre>  it( &#39;Website Should Load&#39;, async () =&gt; {<br>    const response = await page.goto(&#39;http://localhost:3000&#39;, {timeout: 0, waitUntil: &#39;domcontentloaded&#39;});</pre><pre>    assert.strictEqual( response.status(), 200);<br>  });</pre><pre>  it( &#39;Browser Closes Successfully&#39;, async () =&gt; {<br>    await browser.close();<br>  });<br>});</pre><ul><li>Mocha will blow if each test takes more than 2 seconds.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/630/1*3jZHtzXSpx8R3I3zjf8veA.png" /></figure><ul><li>To fix this, you can disable the timeout.</li></ul><pre>it( &#39;Website Should Load Successfully&#39;, async () =&gt; {<br>  console.log( &#39;Go to localhost:3000&#39; );</pre><pre>  await page.goto(&#39;http://localhost:3000&#39;, {waitUntil: &#39;domcontentloaded&#39;});<br>}).timeout(0);</pre><ul><li>Or, you can set the timeout in package.json. In this case, I’m setting the timeout to 10 seconds.</li></ul><pre>&quot;test&quot;: &quot;./node_modules/mocha/bin/mocha --timeout 10000 lib/js/tests/index.js&quot;,</pre><h4>Hooks</h4><p>Mocha provides convenient <a href="https://mochajs.org/#hooks">hooks</a> that will run before or after all the tests. Here I am opening the browser, a new page and setting the viewport before running any tests. And when all the tests are complete, the browser will close.</p><pre>describe( &#39;Website on Desktop View&#39;, async () =&gt; {</pre><pre>  let browser, page;</pre><pre>  before(async () =&gt; {</pre><pre>    browser = await puppeteer.launch( opts );</pre><pre>    page = await browser.newPage();</pre><pre>    await page.setViewport( { width: 1280, height: 800} );</pre><pre>  });</pre><pre>  after(async () =&gt; {</pre><pre>    await browser.close();</pre><pre>  });</pre><pre>});</pre><h4>Try / Catch</h4><p>It will be a great benefit to use try/catch statements for each test. Here, I am checking to see if I am getting a response status of 200. If unsuccessful, I will receive an error and will take a screenshot of the page and close browser instead of running the rest of the tests.</p><pre>it( &#39;Website Should Load Successfully&#39;, async () =&gt; {</pre><pre>  let response;</pre><pre>  try {</pre><pre>    response = await page.goto(&#39;<a href="https://thoughtcatalog.com/&#39;">http://localhost:3000/&#39;</a>, {</pre><pre>      timeout: 0,<br>      waitUntil: &#39;domcontentloaded&#39;</pre><pre>  });</pre><pre>  console.log( &#39;Response Status: &#39; + response.status() );</pre><pre>  } catch ( err ) {</pre><pre>    console.log( &#39;Website Failed: Taking a screenshot&#39; );</pre><pre>    await page.screenshot({</pre><pre>      path: `./lib/js/tests/screenshots/FAILED-homepage_fullpage-desktop.jpeg`,<br>      fullPage: true</pre><pre>    });</pre><pre>    await browser.close();</pre><pre>  }</pre><pre>  assert.strictEqual( response.status(), 200 );</pre><pre>});</pre><p>I hope this was helpful and you had as much fun as I did. It’s a great alternative that’s easy grasp.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8a5c6feb3407" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Dynamic Event Handlers in React]]></title>
            <link>https://medium.com/cloudboost/dynamic-event-handlers-in-react-f9b8661098c6?source=rss-411985dba33------2</link>
            <guid isPermaLink="false">https://medium.com/p/f9b8661098c6</guid>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[react]]></category>
            <category><![CDATA[front-end-development]]></category>
            <category><![CDATA[javascript]]></category>
            <dc:creator><![CDATA[Daniel Park]]></dc:creator>
            <pubDate>Mon, 28 Aug 2017 02:37:04 GMT</pubDate>
            <atom:updated>2020-07-16T15:08:41.533Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/578/1*WxtSPR9ic-zRwschUbbnHw.png" /></figure><pre>this.state = {<br>  sunday: false,<br>  monday: false,<br>  tuesday: false,<br>  wednesday: false,<br>  thursday: false,<br>  friday: false,<br>  saturday: false,<br>}</pre><p>Let’s say that you had multiple elements that are triggered with an event handler that does the same job which would cause a lot of unnecessary repetition.</p><pre>&lt;div&gt;<br>  &lt;input type=&quot;checkbox&quot; onChange={props.handleSunday}&gt;&lt;/input&gt;<br>  &lt;label&gt;Sunday&lt;/label&gt;</pre><pre>  &lt;input type=&quot;checkbox&quot; onChange={props.handleMonday}&gt;&lt;/input&gt;<br>  &lt;label&gt;Monday&lt;/label&gt;</pre><pre>  &lt;input type=&quot;checkbox&quot; onChange={props.handleTuesday}&gt;&lt;/input&gt;<br>  &lt;label&gt;Tuesday&lt;/label&gt;</pre><pre>  &lt;input type=&quot;checkbox&quot; onChange={props.handleWednesday}&gt;&lt;/input&gt;<br>  &lt;label&gt;Wednesday&lt;/label&gt;</pre><pre>  &lt;input type=&quot;checkbox&quot; onChange={props.handleThursday}&gt;&lt;/input&gt;<br>  &lt;label&gt;Thursday&lt;/label&gt;</pre><pre>  &lt;input type=&quot;checkbox&quot; onChange={props.handleFriday}&gt;&lt;/input&gt;<br>  &lt;label&gt;Friday&lt;/label&gt;</pre><pre>  &lt;input type=&quot;checkbox&quot; onChange={props.handleSaturday}&gt;&lt;/input&gt;<br>  &lt;label&gt;Saturday&lt;/label&gt;<br>&lt;/div&gt;</pre><p>The event handler below would look like this. You would require seven separate event handler to handle each day that’s doing the exact same job. This would be very un-DRY.</p><pre>handleSunday = () =&gt; {this.setState({Sunday: !this.state.Sunday}) }</pre><pre>handleMonday = () =&gt; {this.setState({Monday: !this.state.Monday}) }</pre><pre>handleTuesday = () =&gt; {this.setState({Tuesday: !this.state.Tuesday}) }</pre><pre>//this would go on and on....</pre><p>One of the easiest way to make this more dynamic is by adding a name attribute to your elements that is the same as the name of your state. You can use event.target.name</p><pre>&lt;div&gt;<br>  &lt;input type=&quot;checkbox&quot; name=&quot;sunday&quot; onChange={props.handleDay}&gt;&lt;/input&gt;<br>  &lt;label&gt;Sunday&lt;/label&gt;</pre><pre>&lt;input type=&quot;checkbox&quot; name=&quot;monday&quot; onChange={props.handleDay}&gt;&lt;/input&gt;<br>  &lt;label&gt;Monday&lt;/label&gt;</pre><pre>&lt;input type=&quot;checkbox&quot; name=&quot;tuesday&quot; onChange={props.handleDay}&gt;&lt;/input&gt;<br>  &lt;label&gt;Tuesday&lt;/label&gt;</pre><pre>&lt;input type=&quot;checkbox&quot; name=&quot;wednesday&quot; onChange={props.handleDay}&gt;&lt;/input&gt;<br>  &lt;label&gt;Wednesday&lt;/label&gt;</pre><pre>&lt;input type=&quot;checkbox&quot; name=&quot;thursday&quot; onChange={props.handleDay}&gt;&lt;/input&gt;<br>  &lt;label&gt;Thursday&lt;/label&gt;</pre><pre>&lt;input type=&quot;checkbox&quot; name=&quot;friday&quot; onChange={props.handleDay}&gt;&lt;/input&gt;<br>  &lt;label&gt;Friday&lt;/label&gt;</pre><pre>&lt;input type=&quot;checkbox&quot; name=&quot;saturday&quot; onChange={props.handleDay}&gt;&lt;/input&gt;<br>  &lt;label&gt;Saturday&lt;/label&gt;<br>&lt;/div&gt;</pre><p>Now you have one handler that is reusable.</p><pre>handleDay = (event) =&gt; {<br>    let name = event.target.name<br>    this.setState({<br>      [name]: event.target.checked<br>    })<br>  }</pre><p>This is just one simple example out of the many different possibilities to make your event handlers reusable.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f9b8661098c6" width="1" height="1" alt=""><hr><p><a href="https://medium.com/cloudboost/dynamic-event-handlers-in-react-f9b8661098c6">Dynamic Event Handlers in React</a> was originally published in <a href="https://medium.com/cloudboost">CloudBoost</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Reasons for Single Page Applications]]></title>
            <link>https://medium.com/cloudboost/single-page-applications-985b28471774?source=rss-411985dba33------2</link>
            <guid isPermaLink="false">https://medium.com/p/985b28471774</guid>
            <category><![CDATA[single-page-applications]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[react]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[front-end-development]]></category>
            <dc:creator><![CDATA[Daniel Park]]></dc:creator>
            <pubDate>Mon, 21 Aug 2017 03:59:42 GMT</pubDate>
            <atom:updated>2017-08-21T13:24:05.767Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/563/1*6i9z4cxn1g2v1WCuEw6nOQ.png" /></figure><p>Here’s a short history of why more and more companies are using single-page applications.</p><p>In the beginning, when applications consisted nothing but simple HMTL and CSS, it didn’t have to worry about the user state and each view could be regenerated by sending a new request to the server.</p><p>Below is an example of a simple page of what a website in the earlier days might’ve looked like. You’ll notice that there’s not much happening. There aren’t any gif’s, images, videos or even many colors like all of today’s websites.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jnxztsOJr7SjjfJHMDeOXA.png" /><figcaption>An example of a simple website</figcaption></figure><p>But over time, applications became more complex. Reloading the whole page, when just one part of it changes, was ineffective and slow.</p><h3>So why is this important?</h3><p>According to Google’s Site Performance for Webmasters, “<strong>2 seconds</strong> is the threshold for e-commerce website acceptability”</p><p><a href="http://www.fastcompany.com/1825005/how-one-second-could-cost-amazon-16-billion-sales"><strong>Amazon has discovered</strong></a> that for every one second delay, conversions dropped by 7%. If you sell $100k per day, that’s an annual loss of $2.5m.</p><p><a href="http://www.globaldots.com/how-website-speed-affects-conversion-rates/"><strong>Walmart has found</strong></a> that it gains 1% revenue increase for every 100ms of improvement.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/618/1*CcJrjdchdnCEYMN9GDYCuw.png" /></figure><h3>JavaScript to the rescue</h3><p>JavaScript/jQuery brought significant advances to front-end web development.</p><p>It provided simple and effective out-of-the-box capabilities such as client side validation, modal windows, alert messages, animations, and even Ajax-based partial page updates.</p><p>This is all possible because of the DOM</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/952/0*6y62e8j_YJokAEWY." /></figure><p>But DOM trees are huge nowadays.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/571/0*9L4p3GFIfNhdfDxb." /></figure><p>We are pushing more and more towards dynamic websites. That means that we are constantly modifying the DOM tree.</p><h3>This is a real performance and development pain.</h3><p>The DOM works in a<em> retained mode</em>, which means that it only remembers the current state. In order to modify our view, we need to provide instructions for each DOM element and program the transition. So every time we click on something, it finds every node interested on an event and updates it if necessary.</p><p>We easily end up with spaghetti code.</p><p>This takes a big toll on performance and it becomes a big pain for developers.</p><p>There are two main problems:</p><ol><li>It’s hard to manage. Imagine that you have to tweak an event handler. If you lost the context, you have to dive really deep into the code to even know what’s going on. Both time-consuming and bug-risky.</li><li>It’s inefficient. Do we really need to do all this findings manually? Maybe we can be smarter and tell in advance which nodes are to-be-updated?</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/618/1*CcJrjdchdnCEYMN9GDYCuw.png" /></figure><h3>Single Page Applications</h3><p>A single page application literally has only one page. One of the main purposes is to reduce amount of page refreshes. Rendering pages are handled mostly on the client-side.</p><p>Here are some popular JavaScript frameworks for building SPA’s that you can check out.</p><ul><li><a href="https://angular.io/">Angular</a></li><li><a href="https://facebook.github.io/react/">React</a></li><li><a href="http://emberjs.com/">Ember</a></li><li><a href="http://aurelia.io/">Aurelia</a></li><li><a href="https://vuejs.org/">Vue.js</a></li><li><a href="http://cycle.js.org/">Cycle.js</a></li><li><a href="http://backbonejs.org/">Backbone</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=985b28471774" width="1" height="1" alt=""><hr><p><a href="https://medium.com/cloudboost/single-page-applications-985b28471774">Reasons for Single Page Applications</a> was originally published in <a href="https://medium.com/cloudboost">CloudBoost</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Using Inline styles in JSX]]></title>
            <link>https://medium.com/cloudboost/using-inline-styles-in-jsx-c1d03cbe6fe0?source=rss-411985dba33------2</link>
            <guid isPermaLink="false">https://medium.com/p/c1d03cbe6fe0</guid>
            <category><![CDATA[react]]></category>
            <category><![CDATA[css]]></category>
            <category><![CDATA[jsx]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[web-development]]></category>
            <dc:creator><![CDATA[Daniel Park]]></dc:creator>
            <pubDate>Sun, 13 Aug 2017 21:21:17 GMT</pubDate>
            <atom:updated>2017-08-16T17:41:14.590Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/593/1*QRDHGdyEq7RhBq5CgtGS0A.gif" /></figure><p>JSX gives us the convenience of combining HTML syntax and JavaScript under one file in React. However, our stylesheets always existed in a separate directory. With inline styles, you have to option to combine CSS syntax with JSX code.</p><h4>Syntax</h4><p>Let’s say that we wanted to build a yellow square.</p><pre>import React from &#39;react&#39;</pre><pre>function ColorBlock() {<br>  let styles = {<br>    margin: &#39;20px&#39;,<br>    width: &#39;250px&#39;,<br>    height: &#39;250px&#39;,<br>    backgroundColor: &#39;yellow&#39;,<br>  };</pre><pre>  return (<br>    &lt;div&gt;<br>      &lt;div className=&quot;yellow-box&quot; style={styles}&gt;<br>      &lt;/div&gt;<br>    &lt;/div&gt;<br>  )<br>}</pre><pre>export default ColorBlock</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/285/1*aXaofIxfpteBtE_SGYvKAQ.png" /></figure><p>You’ll notice a couple of things.<br>- The CSS attributes and values are stored in an object. Therefore, you must use <strong><em>comma’s instead of semi-colons</em></strong> to separate your declarations.<br>- Attribute names are in <strong><em>camelCase instead of using hyphens</em></strong>.</p><p>Now what if you wanted to build another box with different values?</p><pre>import React from &#39;react&#39;</pre><pre>function ColorBlock() {<br>  var styles1 = {<br>    margin: &#39;20px&#39;,<br>    width: &#39;250px&#39;,<br>    height: &#39;250px&#39;,<br>    backgroundColor: &#39;yellow&#39;,<br>    display: &#39;inline-block&#39;,<br>  };</pre><pre>  var styles2 = {<br>    margin: &#39;20px&#39;,<br>    width: &#39;200px&#39;,<br>    height: &#39;200px&#39;,<br>    backgroundColor: &#39;blue&#39;,<br>    display: &#39;inline-block&#39;,<br>  };</pre><pre>  return (<br>    &lt;div&gt;<br>      &lt;div className=&quot;square-box&quot; style={styles1}&gt;<br>      &lt;/div&gt;<br>      &lt;div className=&quot;square-box&quot; style={styles2}&gt;<br>      &lt;/div&gt;<br>    &lt;/div&gt;<br>  )<br>}</pre><pre>export default ColorBlock</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/525/1*NnM8NYNNvW5o-gZmvBH6Ag.png" /></figure><p>Why would anyone want to do this? It makes more sense to just have separate stylesheets.</p><p>What if you wanted to generate a random color? I can’t think of a way to generate random colors in CSS (or at least that I’m aware of). But I would know how to do that in JavaScript.</p><h4>Math.random()</h4><p>JavaScript gives us a wonderful method called Math.random().</p><pre>Math.random()<br>=&gt; 0.8535371342594502<br></pre><pre>Math.floor(Math.random() * 10)<br>=&gt; random number (0 - 9)</pre><h4>RGB (Red Green Blue) color</h4><p>These three colors are added together in various ways to reproduce a broad array of colors. The RGB range for each color is from 0 to 255.</p><p>255 * 255 * 255 = 16,777,216 different possible colors.</p><pre>#p1 {color: rgb(255, 0, 0);}   /* red */<br>#p2 {color: rgb(0, 255, 0);}   /* green */<br>#p3 {color: rgb(0, 0, 255);}   /* blue */</pre><p>Now let’s implement all this in React.</p><pre>import React from &#39;react&#39;</pre><pre>function ColorBlock() {<br>  let rgb = []</pre><pre>  for (var i = 0; i &lt; 3; i++) {<br>    let r = Math.floor(Math.random() * 256)<br>    rgb.push(r)<br>  }</pre><pre>  var styles = {<br>    margin: &#39;20px&#39;,<br>    width: &#39;250px&#39;,<br>    height: &#39;250px&#39;,<br>    backgroundColor: `rgb(${rgb})`,<br>    display: &#39;inline-block&#39;,<br>  };</pre><pre>  return (<br>    &lt;div&gt;<br>      &lt;div className=&quot;square-box&quot; style={styles}&gt;<br>      &lt;/div&gt;<br>    &lt;/div&gt;<br>  )<br>}</pre><pre>export default ColorBlock</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/283/1*qr9OHxWKaBtrQpArwNBEuw.png" /><figcaption><strong>First Render</strong></figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/273/1*0XPll3zgDlF0k4_swEvvog.png" /><figcaption><strong>Second Render</strong></figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/279/1*uaJx6JrXADMT53AP6iXY6w.png" /><figcaption><strong>Third Render</strong></figcaption></figure><h4>So React styles: Yay or Nay?</h4><p>There’s a lot of talk of whether inline styles should be used or not and many argued that it’s bad practice. In my opinion, I would say that it should be used only when necessary especially when some JavaScript logic is required. I can’t imagine the many lines of CSS code on top of the JSX code. I recommending this <a href="https://blog.jumpcut.com/how-should-you-style-your-react-app-89ced099643"><strong>blog</strong></a> to weigh in the pro’s and con’s.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c1d03cbe6fe0" width="1" height="1" alt=""><hr><p><a href="https://medium.com/cloudboost/using-inline-styles-in-jsx-c1d03cbe6fe0">Using Inline styles in JSX</a> was originally published in <a href="https://medium.com/cloudboost">CloudBoost</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Time/Date in React using setInterval]]></title>
            <link>https://medium.com/@dpark/time-date-in-react-using-setinterval-54ece428e0cf?source=rss-411985dba33------2</link>
            <guid isPermaLink="false">https://medium.com/p/54ece428e0cf</guid>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[react]]></category>
            <category><![CDATA[time-tracking]]></category>
            <category><![CDATA[web-design]]></category>
            <dc:creator><![CDATA[Daniel Park]]></dc:creator>
            <pubDate>Sat, 05 Aug 2017 06:38:37 GMT</pubDate>
            <atom:updated>2017-08-05T06:43:47.487Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/222/1*SRWlpP1a_EW-76KlIhct7w.gif" /></figure><h4>new Date()</h4><p>new Date() creates a new JavaScript <strong>Date</strong> instance.</p><pre>new Date()</pre><pre>=&gt; Sat Aug 05 2017 01:33:05 GMT-0400 (EDT)</pre><p>This is different from Date() which returns a string.</p><pre>Date()</pre><pre>=&gt; &#39;Sat Aug 05 2017 01:33:05 GMT-0400 (EDT)&#39;</pre><p>Since it is an object, it can be store in a variable.</p><pre>var currentTimeDate = new Date()</pre><h4>Date.prototype Methods</h4><p>All <strong>Date</strong> instances inherit from <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/prototype"><strong><em>Date.prototype</em></strong></a> which gives you a variety of methods such as getHours() or getMonth().</p><pre>currentTimeDate.getDay()<br>=&gt; 6 <em><br>(Returns the day of the week (0-6))</em></pre><pre>currentTimeDate.getMonth()<br>=&gt; 7<em> <br>(Returns the month (0-11))</em></pre><pre>currentTimeDate.getDate()<br>=&gt; 5 <em><br>(Returns the day of the month (1-31))</em></pre><pre>currentTimeDate.getFullYear()<br>=&gt; 2017<em><br>(Returns the year (4 digits for 4-digit years))</em></pre><pre>currentTimeDate.getHours()<br>=&gt; 2<br><em>(Returns the hour (0-23))</em></pre><pre>currentTimeDate.getMinutes()<br>=&gt; 43 <br><em>(Returns the minutes (0-59))</em></pre><pre>currentTimeDate.getSeconds()<br>=&gt; 14<br><em>(Returns the seconds (0-59))</em></pre><h4>setInterval()</h4><p>setInterval is a method that calls a function repeatedly with an established time delay.</p><p>For example, let’s say that we have a simple function:</p><pre>function hello() {<br>  console.log(&quot;Hello World&quot;)<br>}</pre><p>We all know what would happen when we call that function.</p><pre>hello()</pre><pre>=&gt; &quot;Hello World&quot;</pre><p>What if we call this function repeatedly using the setInterval method?</p><pre>setInterval(hello, 1000)</pre><pre>=&gt; &quot;Hello World&quot;<br>=&gt; &quot;Hello World&quot;<br>=&gt; &quot;Hello World&quot;<br>=&gt; &quot;Hello World&quot;<br>=&gt; &quot;Hello World&quot;  <em>(Will call the hello function every second)</em></pre><p>The setInterval method must take a <strong><em>function as the first argument</em></strong> and an integer that represents the <strong><em>delay as the second argument</em></strong>. Every 1000 delay is 1 second.</p><h4>Time and Date in React</h4><p>Now that you know how Date() and setInterval() works, you can implement this in your React app. Since getMonth() and getDay() returns in integer, you would have to establish their string formats in an array.</p><pre>import React, {Component} from &#39;react&#39;<br>import &#39;../styles/TimeDate.css&#39;;</pre><pre>class TimeContainer extends Component {</pre><pre>  constructor() {<br>    super()</pre><pre>    let d = new Date()<br>      this.state = {<br>        day: d.getDay(),<br>        month: d.getMonth(),<br>        date: d.getDate(),<br>        year: d.getFullYear(),<br>        time: d.toLocaleTimeString()<br>      }</pre><pre>    this.countingSecond = this.countingSecond.bind(this)<br>  }</pre><pre>  countingSecond() {<br>    let d = new Date()<br>    this.setState({<br>      day: d.getDay(),<br>      month: d.getMonth(),<br>      date: d.getDate(),<br>      year: d.getFullYear(),<br>      time: d.toLocaleTimeString()<br>    })<br>  }</pre><pre>  componentWillMount() {<br>    setInterval(this.countingSecond, 1000)<br>  }</pre><pre>  render() {<br>    const months = [&quot;January&quot;, &quot;February&quot;, &quot;March&quot;, &quot;April&quot;, &quot;May&quot;, &quot;June&quot;, &quot;July&quot;, &quot;August&quot;, &quot;September&quot;, &quot;November&quot;, &quot;December&quot;]<br>    const days = [&quot;Sunday&quot;, &quot;Monday&quot;, &quot;Tuesday&quot;, &quot;Wednesday&quot;, &quot;Thursday&quot;, &quot;Friday&quot;, &quot;Saturday&quot;]</pre><pre>  return (<br>      &lt;div className=&#39;timeclock-main&#39;&gt;<br>        &lt;h3 className=&#39;timeclock-text&#39;&gt;{days[this.state.day]}, {months[this.state.month]} {this.state.date}, {this.state.year} {this.state.time}&lt;/h3&gt;<br>      &lt;/div&gt;<br>    )<br>  }<br>}</pre><pre>export default TimeContainer</pre><p>Now you have a clock live on your website!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/480/1*zsq90MKRWxJn-FkFJRNuDw.gif" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=54ece428e0cf" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Font Awesome is awesome]]></title>
            <link>https://medium.com/@dpark/font-awesome-is-awesome-77d8ee8bdb26?source=rss-411985dba33------2</link>
            <guid isPermaLink="false">https://medium.com/p/77d8ee8bdb26</guid>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[font-awesome]]></category>
            <category><![CDATA[css]]></category>
            <category><![CDATA[web-design]]></category>
            <category><![CDATA[html]]></category>
            <dc:creator><![CDATA[Daniel Park]]></dc:creator>
            <pubDate>Sun, 30 Jul 2017 01:18:07 GMT</pubDate>
            <atom:updated>2017-07-30T01:18:07.421Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*GmsdRvcT7GsG9Bn5ur1fQQ.png" /></figure><p>Font Awesome is a collection of stylish icons that can easily be used by either using a CDN or by downloading the entire directory into your project. There are currently 675 icons to choose from. The collection can be found <a href="http://fontawesome.io/icons/">here</a>.</p><p>The icons are vectors so they look great in any resolution.</p><h4>CDN</h4><p>Insert this code in your HTML’s &lt;head&gt;</p><pre>&lt;link href=&quot;<a href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css">https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css</a>&quot; rel=&quot;stylesheet&quot; integrity=&quot;sha384-wvfXpqpZZVQGK6TAh5PVlGOfQNHSoD2xbE+QkPxCAFlNEevoEH3Sl0sibVcOQVnN&quot; crossorigin=&quot;anonymous&quot;&gt;</pre><h4>or Download</h4><p>You can also download the entire directory into your project. You can either use the default styling or manually customize the icons yourself. The link for the download can be found <a href="http://fontawesome.io/get-started/">here</a>.</p><p>In the &lt;head&gt; of your html, reference the location to your font-awesome.min.css.</p><pre>&lt;link rel=&quot;stylesheet&quot; href=&quot;styles/font-awesome-4.7.0/css/font-awesome.min.css&quot;&gt;</pre><h4>Implementation</h4><p>It’s amazing how easy it is to incorporate these icons into your app. All you need to do is name your class after the <strong><em>icon name</em></strong> like this:</p><pre>&lt;i class=&quot;fa fa-slack&quot;&gt;&lt;/i&gt;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/159/1*4a3VjitCCa5j7tde2CMYgw.png" /></figure><h4>Styling</h4><p>You can apply styling just how you would for texts.</p><pre>.fa {<br>  font-size: 10em;<br>  color: #ff6f69;<br>  padding: 20px;<br>  border: 3px solid #96ceb4;<br>  border-radius: 25px;<br>}</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/201/1*WMJmuYuNAASuwrmraf0aCQ.png" /></figure><h4>Extensions</h4><p>You can also find more fonts at <a href="http://fizzed.com/oss/font-mfizz">font-mfizz</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MP26_w8JJXcHSqNSuNMNiw.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=77d8ee8bdb26" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[CSS Variables (aka custom properties)]]></title>
            <link>https://medium.com/@dpark/css-variables-aka-custom-properties-c4339e93cd9?source=rss-411985dba33------2</link>
            <guid isPermaLink="false">https://medium.com/p/c4339e93cd9</guid>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[front-end-development]]></category>
            <category><![CDATA[css]]></category>
            <category><![CDATA[web-design]]></category>
            <category><![CDATA[html]]></category>
            <dc:creator><![CDATA[Daniel Park]]></dc:creator>
            <pubDate>Sat, 22 Jul 2017 06:46:24 GMT</pubDate>
            <atom:updated>2017-07-22T06:50:17.964Z</atom:updated>
            <content:encoded><![CDATA[<h3>What is a variable?</h3><p>Before we begin, we should ask ourselves “What is a variable?”. Sounds familiar? Variables are used to store data (in memory) so that it can be referenced for later use.</p><pre>name = &quot;Daniel&quot;</pre><h3>Why use a variable?</h3><p>It is useful for reducing repetition which is the essence of DRY (Don’t Repeat Yourself). Just like in any part of programming, CSS can get very long and messy very quickly. What if you couldn’t remember what value for a certain element? It can be difficult to maintain even for the simplest of things such as figuring out what the hex color of the“main-background-color”. Naming can often be overlooked but it is one of the most important property for a programmer. A good name can be one of the most difficult task to do.</p><h3>Declaring a variable and assigning a value to it</h3><p>You would use <strong><em>:root</em> </strong>as the selector.</p><pre>:root {<br>  --main-bg-color: yellow;<br>  --main-font-color: blue;<br>}</pre><h3>Calling a variable</h3><p>When calling a variable, you would use the <strong><em>var() </em></strong>function and the <strong><em>variable name</em></strong> as the argument within the parenthesis<strong><em>.</em></strong></p><pre>p { <br>  color: var(--main-font-color); <br>}</pre><p>HMTL</p><pre>&lt;body&gt;<br>  &lt;h1&gt;Hello World&lt;/h1&gt;<br>  &lt;div class=&#39;row1&#39;&gt;<br>    &lt;div class=&#39;box&#39;&gt;My Name is Daniel&lt;/div&gt;<br>    &lt;div class=&#39;box&#39;&gt;I live in NYC&lt;/div&gt;<br>    &lt;div class=&#39;box&#39;&gt;I love coding&lt;/div&gt;<br>  &lt;/div&gt;<br>  &lt;div class=&#39;row2&#39;&gt;<br>    &lt;div class=&#39;box&#39;&gt;My Name is John&lt;/div&gt;<br>    &lt;div class=&#39;box&#39;&gt;I live in Austin&lt;/div&gt;<br>    &lt;div class=&#39;box&#39;&gt;I love BBQ&lt;/div&gt;<br>  &lt;/div&gt;<br>  &lt;div class=&#39;row3&#39;&gt;<br>    &lt;div class=&#39;box&#39;&gt;My Name is Jane&lt;/div&gt;<br>    &lt;div class=&#39;box&#39;&gt;I live in LA&lt;/div&gt;<br>    &lt;div class=&#39;box&#39;&gt;I love biking&lt;/div&gt;<br>  &lt;/div&gt;<br>&lt;/body&gt;</pre><p>CSS</p><p>The beauty of CSS variables is that if you decide to change the value of multiple elements that shares the same value, you can only change it in one place instead of every selector. ‘row1’ and ‘row2’ share the same font color. If I decide to change it, I’d only have to change it in one place.</p><pre>:root {<br>  --row1-bg-color: #96ceb4;<br>  --row2-bg-color: #ffeead;<br>  --row3-bg-color: #ff6f69;<br>  --primary-font-color: black;<br>  --secondary-font-color: gray;<br>  --box-font-color: white;<br>}</pre><pre>h1 {<br>  color: #ff6f69;<br>  text-align: center;<br>}</pre><pre>body {<br>  font-family: &quot;Trebuchet MS&quot;, Helvetica, sans-serif;<br>}</pre><pre>:root {<br>  --row1-bg-color: #96ceb4;<br>  --row2-bg-color: #ffeead;<br>  --row3-bg-color: #ff6f69;<br>  --primary-font-color: black;<br>  --secondary-font-color: white;<br>  --third-font-color: gray;<br>}</pre><pre>h1 {<br>  color: #ff6f69;<br>  text-align: center;<br>}</pre><pre>body {<br>  font-family: &quot;Trebuchet MS&quot;, Helvetica, sans-serif;<br>}</pre><pre>.box {<br>  width: 25%;<br>  height: 25%;<br>  border: 1px solid gray;<br>  display: inline-block;<br>  text-align: center;<br>  margin: 10px;<br>  padding: 20px;<br>  color: var(--primary-font-color);<br>}</pre><pre>.row1, .row2, .row3{<br>   text-align: center;<br>}</pre><pre>.row1 .box {<br>  background-color: var(--row1-bg-color);<br>  color: var(--secondary-font-color);<br>}</pre><pre>.row2 .box {<br>  background-color: var(--row2-bg-color);<br>  color: var(--third-font-color);<br>}</pre><pre>.row3 .box {<br>  background-color: var(--row3-bg-color);<br>  color: var(--secondary-font-color);<br>}</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JQspZRUWcnuBPtysA7m4aA.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c4339e93cd9" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Using React’s Perf with react-addons-perf]]></title>
            <link>https://medium.com/@dpark/using-reacts-perf-with-react-addons-perf-77ed260f2df0?source=rss-411985dba33------2</link>
            <guid isPermaLink="false">https://medium.com/p/77ed260f2df0</guid>
            <category><![CDATA[react]]></category>
            <dc:creator><![CDATA[Daniel Park]]></dc:creator>
            <pubDate>Mon, 19 Jun 2017 15:30:32 GMT</pubDate>
            <atom:updated>2017-06-19T15:30:32.030Z</atom:updated>
            <content:encoded><![CDATA[<p>Benchmark your React component or see performance problems in your React apps by using react-addons-perf.</p><h4>Setup</h4><p>In your console, run</p><pre>npm install --save-dev react-addons-perf</pre><p>then import into your App.js file</p><pre>import Perf from &#39;react-addons-perf&#39;</pre><p>The Perf object can be used with React in development mode only. You should not include this bundle when building your app for production. To check which mode you’re in, you can add the React Developer Tools Chrome extension <a href="https://chrome.google.com/webstore/detail/react-developer-tools/fmkadmapgofadopljbjfkapdkoienihi?hl=en">here</a>.</p><p>You’re in production mode if the icon is black.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*8gbCsfMcWneZWrhMi1Iynw.png" /></figure><p>You’re in development mode if the icon is red.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*XKn0kUny4AbkiTwkaDzxQw.png" /></figure><p>Basically by default, when in development mode, the app comes with many helpful warnings that are useful for developers but they take up more space and make the app slower.</p><p>So in order to enter production mode, you can follow the instructions at <br><a href="https://reactjsnews.com/how-to-make-your-react-apps-10x-faster">https://reactjsnews.com/how-to-make-your-react-apps-10x-faster</a><br>or<br><a href="https://stackoverflow.com/questions/22118915/how-to-turn-on-off-reactjs-development-mode">https://stackoverflow.com/questions/22118915/how-to-turn-on-off-reactjs-development-mode</a></p><p>There are a total of eight functions calls:</p><ul><li><a href="https://facebook.github.io/react/docs/perf.html#start">start()</a></li><li><a href="https://facebook.github.io/react/docs/perf.html#stop">stop()</a></li><li><a href="https://facebook.github.io/react/docs/perf.html#getlastmeasurements">getLastMeasurements()</a></li><li><a href="https://facebook.github.io/react/docs/perf.html#printinclusive">printInclusive()</a></li><li><a href="https://facebook.github.io/react/docs/perf.html#printexclusive">printExclusive()</a></li><li><a href="https://facebook.github.io/react/docs/perf.html#printwasted">printWasted()</a></li><li><a href="https://facebook.github.io/react/docs/perf.html#printoperations">printOperations()</a></li><li><a href="https://facebook.github.io/react/docs/perf.html#printdom">printDOM()</a></li></ul><p>For now, we’ll just use</p><ul><li><a href="https://facebook.github.io/react/docs/perf.html#start">start()</a></li><li><a href="https://facebook.github.io/react/docs/perf.html#stop">stop()</a></li><li><a href="https://facebook.github.io/react/docs/perf.html#printexclusive">printExclusive()</a></li><li><a href="https://facebook.github.io/react/docs/perf.html#printwasted">printWasted()</a></li></ul><p>Calling the Perf.start() function starts the performance. We would want to put that in an event handler such as</p><pre>handleClick(event) {<br>    Perf.start()</pre><pre>    event.preventDefault()<br>    this.setState({<br>      clickedRecipe: event.target.innerText<br>    })<br>  }</pre><p>and end the performance once the component has been updated</p><pre>componentDidUpdate() {<br>    Perf.stop()<br>    Perf.printInclusive()<br>    Perf.printWasted()<br>  }</pre><p>Then you would see the result in the console</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6SQlikkUKx59bwA5QiSEzw.png" /></figure><p>As you can see, there are several renders taking place and of that there are a couple of wasted time due to unnecessary renders. That is because an update can be caused by changes to props or state .As developers, we should not only strive to render components faster but render only when it is necessary. Upon a completion of a project or rather a component, this is a great way to work backwards to make your app more quicker.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=77ed260f2df0" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[New features for JavaScript in 2017]]></title>
            <link>https://medium.com/@dpark/new-features-for-javascript-in-2017-6a59f9419d96?source=rss-411985dba33------2</link>
            <guid isPermaLink="false">https://medium.com/p/6a59f9419d96</guid>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[ecmascript-6]]></category>
            <category><![CDATA[front-end-development]]></category>
            <dc:creator><![CDATA[Daniel Park]]></dc:creator>
            <pubDate>Fri, 02 Jun 2017 13:34:48 GMT</pubDate>
            <atom:updated>2017-07-22T06:50:02.495Z</atom:updated>
            <content:encoded><![CDATA[<h4>[These are new features depending on when you read this blog.]</h4><p>ES5 vs ES6? Which one do you prefer? Are you still set in your old ways and holding onto your “for loops” to dear life?? Arrow function, map…what are these? Well, you better pack up and move because there more stuff coming your way. Well, its already kinda here so you better get with the program or you gonna be like Internet Explorer.</p><p>Before I tell you about the new features, let me talk to you about ECMA.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/393/1*_pT5KPonrnwqlWvlCpclgQ.png" /></figure><p><strong>EMCA: </strong>European Computer Manufacturers Association<br><strong>Founded in: </strong>1961 (56 years old)<br><strong>Location: </strong>Geneva, Switzerland<br><strong>Purpose: </strong>Standardization of Information and Communication Technology and Consumer Electronics</p><p>EMCA is in charge of setting a whole bunch of standards but the one that we’re most concerned about is ECMA-262 or better known as ECMAScript or more better known as JavaScript. I don’t want to get into why there are so many different names but if you want to know, you can check out this <a href="https://stackoverflow.com/questions/912479/what-is-the-difference-between-javascript-and-ecmascript"><strong>link</strong></a>.</p><p>Since the birth of JavaScript in 1997, ECMAScript has come out with 7 editions. ECMA2016 which came out on June, 2016 has been the most recent one.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/626/1*ibzw9zNB2AJt3AHtf-xD1g.png" /></figure><p>ECMA2016 came with a couple of new features such as <br>the <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Arithmetic_Operators"><strong>exponentiation (**) operator</strong></a></p><pre>//var1 ** var 2</pre><pre>2 ** 3 // 8<br>3 ** 2 // 9</pre><p>and the <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/includes?v=example"><strong>Array.prototype.includes</strong></a></p><pre>//arr.includes(searchElement)</pre><pre>var a = [1, 2, 3];<br>a.includes(2); // true <br>a.includes(4); // false</pre><p>The reason why I mention ECMA is because they are always in the process of approving new features that will to be added into ECMAScript standard which in effect is implemented to JavaScript. There are essentially 4 stages to that process.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/735/1*8L7px1s7ovuYLfQ3A4-BUw.png" /></figure><p>There are 6 new features that are expected to be published this year and are already implemented in most browsers such as Chrome or Firefox. If you’re using Internet Explorer, please stop and use one of the two that I mentioned. They’re much better. The new features are:</p><ol><li><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/values">Object.values()</a> / <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/entries">Object.entries()</a></li><li><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/padStart">String.prototype.padStart()</a> / <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/padEnd">String.prototype.padEnd()</a></li><li><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/getOwnPropertyDescriptors">Object.getOwnPropertyDescriptors()</a></li><li><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Trailing_commas">Trailing commas</a></li><li><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/async_function">Async functions</a></li><li><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/SharedArrayBuffer">Shared memory and atomics</a></li></ol><p>For more Stage 4 or finished proposals, you can check out this <a href="https://github.com/tc39/proposals/blob/master/finished-proposals.md">link</a>.</p><p>To check if your browser is compatible, check out this <a href="http://kangax.github.io/compat-table/es2016plus/">link</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*s80t5icwbjvAkuznI_trXA.png" /></figure><p>If you’re ever wondering why there are different versions of the same browser, that is because some of those are beta versions or beta beta version. For example, Chrome has a Beta channel that is roughly updated every week with major updates that come about every six weeks. This version is right before the Stable channel that most of us use. Below is the list of different Chrome versions.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/246/1*wZbtUPn0qiWMNksm9CDLbg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/123/1*osuK0Tn7tb7KLk2I1hR6IQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/246/1*uj0Kagc8cqXbpFtOh-2i6Q.png" /></figure><ol><li><strong>Stable channel</strong> (the final version)<strong>:</strong> <br>Got the full testing and blessing of the Chrome test team</li><li><strong>Beta channel</strong> (the beta version): <br>Updated every week roughly, with major updates coming every six weeks</li><li><strong>Dev channel</strong> (the beta beta version): <br>Updated once or twice weekly. This build is subject to bugs.</li><li><strong>Canary build</strong> (the beta beta beta version): <br>Released daily! this build has not been tested or used</li></ol><p>For Chrome downloads, click <a href="https://www.chromium.org/getting-involved/dev-channel">here</a>.</p><p>Firefox has their own set of versions.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/154/1*XHYhisOBbdTwJ9jIltmVRQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/156/1*tpP37d67-qJORQYt61Uaiw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/151/1*g9E4oROKBVZrIn_R8OfilQ.png" /></figure><p>For Firefox downloads, click <a href="https://www.mozilla.org/en-US/firefox/channel/desktop/">here</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6a59f9419d96" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[“use strict” in Javascript]]></title>
            <link>https://medium.com/@dpark/use-strict-in-javascript-3b872b969b0f?source=rss-411985dba33------2</link>
            <guid isPermaLink="false">https://medium.com/p/3b872b969b0f</guid>
            <category><![CDATA[javascript]]></category>
            <dc:creator><![CDATA[Daniel Park]]></dc:creator>
            <pubDate>Fri, 12 May 2017 06:59:53 GMT</pubDate>
            <atom:updated>2017-05-12T06:59:53.204Z</atom:updated>
            <content:encoded><![CDATA[<p>We all know that JavaScript can be weird sometimes. There are certain things that we all know that we shouldn’t do but CAN do and get away with it. We can do things like establish a global variable and not cause any errors.</p><pre>x = &quot;happy&quot;;</pre><pre>//Everyone knows that you CAN but SHOULDN’T do this.</pre><p>You probably meant to write…</p><pre>var x = &quot;happy&quot;;</pre><p>Below are a couple of more examples of things that you can do in JavaScript that you really shouldn’t do.</p><p><strong>Setting a function with the same parameter names</strong></p><pre>function funny(a, a) {<br>  console.log(&quot;happy&quot;)<br>}</pre><p><strong>Establishing an object with the same keys.</strong></p><pre>var x = {a: &quot;happy&quot;, a: &quot;cat&quot;};</pre><pre>x; //==&gt; What would &quot;x&quot; look like?</pre><p><strong>Silent failing assignments</strong></p><pre>NaN = 5;</pre><pre>//or</pre><pre>undefined = 5;</pre><p><strong>Deleting plain names or undeletable properties</strong></p><pre>var x = &quot;happy&quot;;<br>delete x;  //==&gt; What happens to &quot;x&quot;?</pre><pre>//or</pre><pre>delete Object.prototype</pre><p><strong>Setting an integer that starts with a zero to a variable</strong></p><pre>var x = 0123;  //&lt;&lt;== what is this?</pre><h4>Implementing Strict Mode</h4><p>Strict Mode is a feature in JavaScript that was introduced in ECMAScript 5. It eliminates some JavaScript silent errors by changing them to throw errors. Strict mode applies to <em>entire scripts</em> or to <em>individual functions</em>. It doesn’t apply to block statements enclosed in {} braces. You can implement strict mode by adding <strong>“use strict”;</strong> to the beginning of a script or a function.</p><p>Strict Mode for scripts</p><pre>&#39;use strict&#39;;  //You&#39;re in Strict Mode!</pre><pre>var x = &quot;Hello World!&quot;;</pre><p>Strict Mode for functions</p><pre>function cool() {<br>  &quot;use strict&quot;;<br>  // ... your code ...<br>  // this function is executed in strict mode<br>}</pre><pre>//anything outside of the function will be in non-strict mode.</pre><p>I‘m not sure how often I’ll use strict mode but I think it’ll come in handy if I were to teach a beginner and to reinforce what I know about JavaScript or if I myself wasn’t sure of committing bad syntax. It’s great to get another level of error messages since we as developers depend on them so much.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3b872b969b0f" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>