{"componentChunkName":"component---src-pages-index-js","path":"/","result":{"data":{"allMarkdownRemark":{"edges":[{"node":{"id":"4becdce3-43e0-5106-8829-c94fd8164a9e","html":"<p><img src=\"/assets/cover/countdown-timer.png\" alt=\"app-logo\"></p>\n<h2>Introduction</h2>\n<p>The countdown timer is a simple app you can build to exercise your skills as a developer. To build the countdown timer you will need the basic knowledge of HTML, CSS, and JavaScript.</p>\n<h2>Building the structure with HTML</h2>\n<p>We are starting with creating a <code>div</code> with a class container which will have all of the <code>div</code> with box class nested inside, the box class <code>div</code> have <code>h2</code> element for the static unit text and <code>p</code> element which will hold the values.</p>\n<pre><code class=\"language-html\">&#x3C;!DOCTYPE html>\n&#x3C;html lang=\"en\">\n&#x3C;head>\n    &#x3C;meta charset=\"UTF-8\">\n    &#x3C;meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">\n    &#x3C;title>Countdown Timer&#x3C;/title>\n    &#x3C;link rel=\"stylesheet\" href=\"style.css\">\n    &#x3C;script defer src=\"main.js\">&#x3C;/script>\n&#x3C;/head>\n&#x3C;body>\n    &#x3C;div class=\"container\">\n        &#x3C;div style=\"width: 130px;\" class=\"box\">\n            &#x3C;h2 id=\"days-text\">Days&#x3C;/h2>\n            &#x3C;p id=\"days\">000&#x3C;/p>\n        &#x3C;/div>\n        &#x3C;div class=\"box\">\n            &#x3C;h2 id=\"hours-text\">Hours&#x3C;/h2>\n            &#x3C;p id=\"hours\">00&#x3C;/p>\n        &#x3C;/div>\n        &#x3C;div class=\"box\">\n            &#x3C;h2 id=\"minutes-text\">Minutes&#x3C;/h2>\n            &#x3C;p id=\"minutes\">00&#x3C;/p>\n        &#x3C;/div>\n        &#x3C;div class=\"box\">\n            &#x3C;h2 id=\"seconds-text\">Secondes&#x3C;/h2>\n            &#x3C;p id=\"seconds\">00&#x3C;/p>\n        &#x3C;/div>\n    &#x3C;/div>\n\n    &#x3C;div style=\"background: rgb(204, 24, 24);\" class=\"alert\">\n        &#x3C;h1 style=\"padding: 50px 80px;color: white;\">Finished!&#x3C;/h1>\n    &#x3C;/div>\n&#x3C;/body>\n&#x3C;/html>\n</code></pre>\n<p><ad-incontent></ad-incontent></p>\n<h2>Styling the structure with CSS</h2>\n<p>The next step is to style our elements which we added previously using CSS.</p>\n<pre><code class=\"language-css\">*{\n    margin: 0;\n    padding: 0;\n    box-sizing: border-box;\n    background: rgb(18, 19, 18);\n}\nbody{\n    height: 100vh;\n    display: flex;\n    align-items: center;\n    justify-content: center;\n}\n.container{\n    width: 600px;\n    height: 200px;\n    display: flex;\n    align-items: center;\n    justify-content: center;\n}\n.box{\n    width: 100px;\n    height: 100px;\n    margin: 0 15px;\n}\nh2{\n    text-align: center;\n    padding-top: 2px;\n    color: blanchedalmond;\n    \n}\n.box p{\n    font-size: 50px;\n    text-align: center;\n    font-family: sans-serif;\n    font-weight: 800;\n    margin-bottom: 15px;\n    color: blanchedalmond;\n}\n.alert{\n    display: none;\n}\n</code></pre>\n<p><ad-incontent></ad-incontent></p>\n<h2>Adding logic with JavaScript</h2>\n<p>Lastly, we will need to add JavaScript for the logic part so our countdown timer can be functional.</p>\n<pre><code class=\"language-javascript\">const finaleTime = new Date(\"January 1, 2022 00:00:00\").getTime();\n\nconst timer = () =>{\n    const currentTime = new Date().getTime();\n    let difference = finaleTime - currentTime;\n    // Displaying the alert when the timer finishes.\n    if(difference &#x3C; 0){\n        document.querySelector('.alert').style.display = 'block';\n        document.querySelector('.container').style.display = 'none';\n    }\n    \n    let days = Math.floor(difference / (1000*60*60*24));\n    let hours = Math.floor(difference % (1000*60*60*24) / (1000*60*60));\n    let minutes = Math.floor(difference % (1000*60*60)/ (1000*60));\n    let seconds = Math.floor(difference % (1000*60) / 1000);\n  // Adding the zeros.\n    days &#x3C;= 99 ? days = `0${days}` : days;\n    days &#x3C;= 9 ? days = `00${days}` : days;\n    hours &#x3C;= 9 ? hours = `0${hours}` : hours;\n    minutes &#x3C;= 9 ? minutes = `0${minutes}` : minutes;\n    seconds &#x3C;= 9 ? seconds = `0${seconds}` : seconds;   \n\n    document.querySelector('#days').textContent = days;\n    document.querySelector('#hours').textContent = hours;\n    document.querySelector('#minutes').textContent = minutes;\n    document.querySelector('#seconds').textContent = seconds;\n\n}\ntimer();\n// Calling the function every 1000 milliseconds.\nsetInterval(timer, 1000);\n</code></pre>\n<p>With this step, we have finished creating our Countdown Timer with JavaScript.</p>\n<h2>Further Reading</h2>\n<p>For more information on learning JavaScript, I highly recommend the following books:</p>\n<ul>\n<li><a href=\"https://www.amazon.com/gp/product/1491924462/ref=as_li_tl?ie=UTF8&camp=1789&creative=9325&creativeASIN=1491924462&linkCode=as2&tag=aleksandarvas-20&linkId=6e0a99c1b807402b79587ae7cb2a0a8e\" style=\"color:#ff7a59;\">You Don't Know Js: Up &#x26; Going</a></li>\n<li><a href=\"https://www.amazon.com/gp/product/1449335586/ref=as_li_tl?ie=UTF8&camp=1789&creative=9325&creativeASIN=1449335586&linkCode=as2&tag=aleksandarvas-20&linkId=63c3d4f7c6db713ec923b7d4590fcdc0\" style=\"color:#ff7a59;\">You Don't Know JS: Scope &#x26; Closures</a></li>\n<li><a href=\"https://www.amazon.com/gp/product/1491904151/ref=as_li_tl?ie=UTF8&camp=1789&creative=9325&creativeASIN=1491904151&linkCode=as2&tag=aleksandarvas-20&linkId=f2d2db01ca6738f099cae0bccea0ecc2\" style=\"color:#ff7a59;\">You Don't Know Js: this &#x26; Object Prototypes</a></li>\n<li><a href=\"https://www.amazon.com/gp/product/1491904194/ref=as_li_tl?ie=UTF8&camp=1789&creative=9325&creativeASIN=1491904194&linkCode=as2&tag=aleksandarvas-20&linkId=eeeb2ca348428616ae5bd5683bd809ee\" style=\"color:#ff7a59;\">You Don't Know Js: Types &#x26; Grammar</a></li>\n<li><a href=\"https://www.amazon.com/gp/product/1491904224/ref=as_li_tl?ie=UTF8&camp=1789&creative=9325&creativeASIN=1491904224&linkCode=as2&tag=aleksandarvas-20&linkId=1c3608eee769d2838e5417beff71f1b1\" style=\"color:#ff7a59;\">You Don't Know Js: Async &#x26; Performance</a></li>\n<li><a href=\"https://www.amazon.com/gp/product/1491904240/ref=as_li_tl?ie=UTF8&camp=1789&creative=9325&creativeASIN=1491904240&linkCode=as2&tag=aleksandarvas-20&linkId=063996cae1419bd933d533bc2b091ddf\" style=\"color:#ff7a59;\">You Don't Know JS: ES6 &#x26; Beyond</a></li>\n</ul>","frontmatter":{"path":"/building-a-countdown-timer-with-javascript/","date":"2021-02-01T12:50:00.619Z","title":"Building a Countdown Timer with JavaScript","author":"Aleksandar Vasilevski","image":"/assets/cover/countdown-timer.png","category":"JavaScript","tags":"#js #javascript #project","featured":true}}},{"node":{"id":"2d05d920-1fb6-5b7d-ae52-3228a73c9158","html":"<p><img src=\"/assets/cover/redux-landscape.png\" alt=\"redux-logo\"></p>\n<h2>Understanding Middleware in Redux</h2>\n<p>If you've used server-side libraries like Express you are probably already familiar with the concept of middleware. The middleware is some piece of code you can put between the framework receiving a request and the framework generating a response. The best thing about the middleware is that it's compostable in a chain.</p>\n<p>In Redux, the middleware solves a different problem from the Express. Here the middleware provides an extension point between dispatching an action and reaching the reducer. The most common situation to use Redux middleware is for logging, crash reporting, asynchronous API calls, routing, and more.</p>\n<p><img src=\"/assets/samples/redux-middleware-schema.png\" alt=\"redux-middleware-schema\"></p>\n<h2>How to use Middleware in Redux</h2>\n<p>The most basic example of using redux middleware is to log the action and the next state every time we are dispatching an action. To start using the middleware in redux firstly we need to import the <code>applyMiddleware</code> from <code>redux</code> package (the <code>createStore</code> and <code>compose</code>).</p>\n<pre><code class=\"language-javascript\">import React from 'react';\nimport ReactDOM from 'react-dom';\nimport { createStore, applyMiddleware, compose } from 'redux';\nimport { Provider } from 'react-redux';\n</code></pre>\n<p><em>Importing packages in index.js</em></p>\n<p><ad-incontent></ad-incontent></p>\n<pre><code class=\"language-javascript\">const logger = store => {\n  return next => {\n    return action => {\n      console.log('[Middleware] Dispatching', action);\n      const result = next(action);\n      console.log('[Middleware] next state', store.getState());\n      return result;\n    }\n  }\n}\n</code></pre>\n<p><em>logger function in index.js</em></p>\n<p>Lastly, we just need to pass the <code>applyMiddleware</code> with the <code>logger</code> function as an argument inside the <code>createStore</code> function and we are done.</p>\n<pre><code class=\"language-javascript\">const composeEnhancers = window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ || compose;\nconst store = createStore(someReducer, composeEnhancers(applyMiddleware(logger)));\n\nReactDOM.render(\n  &#x3C;React.StrictMode>\n    &#x3C;Provider store={store}>\n      &#x3C;App />\n    &#x3C;/Provider>\n  &#x3C;/React.StrictMode>,\n  document.getElementById('root')\n);\n</code></pre>\n<p><em>Putting all together in index.js</em> </p>\n<p>For more information on understanding redux middleware, the following are great resources:</p>\n<ul>\n<li><a href=\"https://redux.js.org/understanding/history-and-design/middleware\" style=\"color:#ff7a59;\">Official documentation</a></li>\n<li><a href=\"https://redux.js.org/tutorials/fundamentals/part-1-overview\" style=\"color:#ff7a59;\">Redux advanced tutorial</a></li>\n</ul>","frontmatter":{"path":"/how-to-use-middleware-in-redux/","date":"2021-01-22T12:40:00.619Z","title":"How to Use Middleware in Redux","author":"Aleksandar Vasilevski","image":"/assets/cover/redux-landscape.png","category":"React","tags":"#react #redux #js #javascript","featured":false}}},{"node":{"id":"a388dabf-4911-50d0-956f-62b936faeee6","html":"<p><img src=\"/assets/cover/fighter-jet.jpg\" alt=\"fighter-jet\"></p>\n<h2>What are Axios Interceptors?</h2>\n<p>Axios interceptors are built-in functions in Axios that calls for every request or response. Axios interceptors can be used in every request before it is sent or to transform the response before being returned to Axios. In simplest words, you can think of interceptors in Axios as middleware in Express. There are two types of Axios interceptors, request interceptors and response interceptors. Let's dive deeper in both types and see how they work and when should you use them.</p>\n<blockquote>\n<p>If you want to learn more about Axios you can check the <a href=\"/axios-http-client/\"><em>Axios Http Client</em></a> or <a href=\"https://github.com/axios/axios\"><em>Axios Github Page</em></a></p>\n</blockquote>\n<h2>Request Interceptor</h2>\n<p>The best way to get started with Axios interceptors is to use <code>console.log()</code> in every HTTP request.</p>\n<pre><code class=\"language-javascript\">const axios = require('axios');\n\naxios.interceptors.request.use(req => {\n  console.log(`${req.method} ${req.url}`);\n  // You must return the request at the end\n  return req;\n});\n\n// Result: \"get https://codespot.org/get\"\nawait axios.get('https://codespot.org/get');\n\n// Result: \"post https://codespot.org/post\"\nawait axios.post('https://codespot.org/post', {});\n</code></pre>\n<p><ad-incontent></ad-incontent></p>\n<h2>Response Interceptor</h2>\n<p>As with HTTP requests, we can also use Axios interceptors in every response we get from the server.</p>\n<pre><code class=\"language-javascript\">const axios = require('axios');\n\naxios.interceptors.response.use(res => {\n  console.log(res.data.json);\n  // You must return the response at the end\n  return res;\n});\n\n// Result \"post https://codespot.org/post\" followed by \"{ code: 200 }\"\nawait axios.post('https://httpbin.org/post', { code: 200 });\n</code></pre>\n<h2>Authorization Header</h2>\n<p>The most common case to use Axios interceptors is to set the authorization header. Most of the times the client needs to send a secret token to the server to authorize the user. With interceptors, you can set the authorization header automatically on every request. </p>\n<pre><code class=\"language-javascript\">axios.interceptors.request.use(req => {\n  req.headers.authorization = 'secret token';\n  return req;\n});\n\nconst res = await axios.get('https://codespot.org/get');\n</code></pre>\n<h2>Error Handling</h2>\n<p>With the response interceptors, you can also elegantly handle errors. This is important for Axios because you will get the generic error message \"Request failed with status code 404\", which usually you won't show to the user.</p>\n<p>To handle errors in Axios you should use <code>axios.interceptors.response.use()</code> function which takes two arguments<code>successHandler</code> and <code>errorHandler</code>, The first one <code>successHandler</code> is called if the request is successful and the <code>errorHandler</code> is called if the request failed.</p>\n<pre><code class=\"language-javascript\">axios.interceptors.response.use(\n  res => res,\n  err => {\n    if (err.response.status === 404) {\n      throw new Error(`${err.config.url} not found`);\n    }\n    throw err;\n  }\n);\n\n// Automatically sets the authorization header because\n// of the request interceptor\nconst err = await axios.get('https://codespot.org/status/404').\n  then(() => null, err => err);\n\nerr.message; // \"https://codespot.org/status/404 not found\"\n</code></pre>\n<p><ad-incontent></ad-incontent></p>\n<h2>Setting Default Global Configuration</h2>\n<p>Sometimes you don't want to intercept the request but you want to set up a global configuration. For example, the domain in the URL address you are sending from your application is always the same. You can set up the base URL in someplace where will be run first (for example in React, index.js is a good place). Also you can set authentication token and much more.</p>\n<pre><code class=\"language-javascript\">//Base URL for every request\naxios.defaults.baseURL = \"https://codespot.org\";\n//Base authentication token\naxios.defaults.headers.common['Authorization'] = \"Token\";\n</code></pre>\n<p><em>index.js</em></p>\n<pre><code class=\"language-javascript\">const axios = require('axios');\n\naxios.interceptors.request.use(req => {\n  console.log(`${req.method} ${req.url}`);\n  return req;\n});\n\n//With the base URL set up now, you don't need to put it in the request path\nawait axios.get('/get');\n</code></pre>\n<p><em>your-request.js</em></p>","frontmatter":{"path":"/how-to-use-axios-interceptors/","date":"2020-10-21T09:25:49.619Z","title":"How to Use Axios Interceptors","author":"Aleksandar Vasilevski","image":"/assets/cover/fighter-jet.jpg","category":"JavaScript","tags":"#js #javascript #axios #http #request","featured":false}}},{"node":{"id":"02c5e829-8ff4-519d-8513-f1559135a992","html":"<p><img src=\"/assets/cover/html.png\" alt=\"html\"></p>\n<p><em>As you start learning HTML5, you will want to build yourself a boilerplate from which you can begin all your HTML-based projects.</em></p>\n<p>In this article, we will take a look at a simple boilerplate HTML5 code for any project.</p>\n<pre><code class=\"language-html\">&#x3C;!doctype html>\n\n&#x3C;html lang=\"en\">\n&#x3C;head>\n  &#x3C;meta charset=\"utf-8\">\n\n  &#x3C;title>The HTML5 Herald&#x3C;/title>\n  &#x3C;meta name=\"description\" content=\"The HTML5 Herald\">\n  &#x3C;meta name=\"author\" content=\"CodeSpot\">\n\n  &#x3C;link rel=\"stylesheet\" href=\"css/styles.css?v=1.0\">\n\n&#x3C;/head>\n\n&#x3C;body>\n  &#x3C;script src=\"js/scripts.js\">&#x3C;/script>\n&#x3C;/body>\n&#x3C;/html>\n</code></pre>\n<p><em>HTML5 template for starting project</em></p>\n<p><ad-incontent></ad-incontent></p>\n<p>Now let’s see what are the significant parts of the markup and why are they important.</p>\n<h2>The Doctype</h2>\n<p>On the top, we have the Document Type Declaration or doctype. This is nothing more than a way to the browser what type of document it’s looking at. In the case of HTML, it means the specific version of the HTML document. The doctype should always be on top of the HTML file.</p>\n<pre><code class=\"language-html\">&#x3C;!doctype html>\n</code></pre>\n<p><em>HTML5 document type declaration</em></p>\n<h2>The html element</h2>\n<p>Next is the <code>html</code> element which has included the <code>lang</code> attribute with a value of <code>en</code>, which specifies that the document is in the English language. The <code>html</code> element has not changed much in the HTML5.</p>\n<pre><code class=\"language-html\">&#x3C;!doctype html>\n&#x3C;html lang=\"en\">\n\n&#x3C;/html>\n</code></pre>\n<h2>The head element</h2>\n<p>The <code>head</code> element is the container for metadata (Metadata is data about the HTML document. Metadata is not displayed). In the <code>head</code> element we typically define:</p>\n<ul>\n<li><code>meta</code> - meta element is for metadata </li>\n<li><code>title</code> - title element is for the page title</li>\n<li><code>link</code> - link element is for external style sheet</li>\n</ul>\n<pre><code class=\"language-html\">&#x3C;!doctype html>\n&#x3C;html lang=\"en\">\n&#x3C;head>\n  &#x3C;meta charset=\"utf-8\">\n\n  &#x3C;title>The HTML5 Herald&#x3C;/title>\n  &#x3C;meta name=\"description\" content=\"The HTML5 Herald\">\n  &#x3C;meta name=\"author\" content=\"CodeSpot\">\n\n  &#x3C;link rel=\"stylesheet\" href=\"css/styles.css?v=1.0\">\n&#x3C;/head>\n&#x3C;/html>\n</code></pre>\n<p><ad-incontent></ad-incontent></p>\n<h2>the body element</h2>\n<p>The <code>body</code> element contains all the contents of an HTML document. In the <code>body</code> element we typically define elements like headings, paragraphs, images, hyperlinks, tables, lists. At the bottom of the body element we also define:</p>\n<ul>\n<li><code>script</code> - script element is used to embed a client-side script (JavaScript).</li>\n</ul>\n<pre><code class=\"language-html\">&#x3C;!doctype html>\n\n&#x3C;html lang=\"en\">\n&#x3C;head>\n  &#x3C;meta charset=\"utf-8\">\n\n  &#x3C;title>The HTML5 Herald&#x3C;/title>\n  &#x3C;meta name=\"description\" content=\"The HTML5 Herald\">\n  &#x3C;meta name=\"author\" content=\"CodeSpot\">\n\n  &#x3C;link rel=\"stylesheet\" href=\"css/styles.css?v=1.0\">\n\n&#x3C;/head>\n\n&#x3C;body>\n  &#x3C;script src=\"js/scripts.js\">&#x3C;/script>\n&#x3C;/body>\n&#x3C;/html>\n</code></pre>\n<p>Putting scripts at the bottom of the body is considered the best practice for embedding JavaScript. This is important for page-loading speed; when a browser sees a script tag, it will pause downloading and rendering the rest of the page while it parses the script. This way the page loads much more slowly when large scripts are included at the top of the page before any content.</p>\n<blockquote>\n<p>In some special cases, the script may need to be placed in the head of your document, to take effect before the browser starts rendering the page.</p>\n</blockquote>","frontmatter":{"path":"/html5-template/","date":"2020-06-26T10:07:49.619Z","title":"HTML5 Template For Starting Project","author":"Aleksandar Vasilevski","image":"/assets/cover/html.png","category":"HTML","tags":"#html #webdev","featured":false}}},{"node":{"id":"5438c993-6c6a-59fe-b7eb-efdc0022a223","html":"<p><img src=\"/assets/cover/html.png\" alt=\"callback\"></p>\n<p><em>This tutorial is for complete beginners in HTML who want to learn basic web development and web design</em></p>\n<h2>What is HTML?</h2>\n<p>HTML stands for <strong>HyperText Markup Language</strong>, and as the name says HTML is not a programming language but a markup language for creating web pages. HTML is strictly presentational, it doesn't have any logic, it is just for displaying elements in a web page like an image, text, list, etc. HTML is a very important part of web development, it is a building block of the web, every web site out there output HTML in the browser, and a web site can be built just with HTML (although will not look very good). To start building web sites with HTML you will need a text editor(Visual Studio Code, Sublime, Atom, etc) and a web browser(Chrome, Firefox, Safari, etc). HTML code lives in <code>.html</code> files and doesn't need a server to be run, it can run simply in a web browser. In most of the cases, there is a <code>index.html</code> which is the home page of a website.</p>\n<h2>How to Write HTML Code</h2>\n<p>To get started we will make a folder called <code>html-for-absolute-beginners</code> and inside that folder, we will make a file called <code>index.html</code>. Then we will\nsimply open that file in our favorite text editor. If we write anything in the <code>index.html</code>, for example, a Hello, World, and then open the same file in our browser we will see the text Hello, World displayed in the browser.</p>\n<pre><code class=\"language-html\">Hello, World\n</code></pre>\n<p><em>index.html</em></p>\n<p>Most of the time we will not write simple text like this in our HTML files, instead, we will be using an <strong>HTML Tags</strong>.</p>\n<p><ad-incontent></ad-incontent></p>\n<h2>HTML Tags and Elements</h2>\n<p>Tags are the building block of HTML, every tag format the information we want to display which can be text, image, etc. HTML element structure looks like this: </p>\n<pre><code>&#x3C;tagname>content&#x3C;/tagname>\n</code></pre>\n<p><em>html element example</em></p>\n<p>Elements usually have a start tag and end tag and content in the middle, in some cases tags close themselves. Tags can be inline or block-level elements.</p>\n<blockquote>\n<p>You can find HTML documentation with every tag/element on the <a href=\"https://developer.mozilla.org/en-US/docs/Web/HTML\"><strong>developer.mozilla.org</strong></a>.</p>\n</blockquote>\n<h2>HTML Page Structure</h2>\n<p><img src=\"/assets/samples/html-structure.png\" alt=\"html-structure\"></p>\n<p><em>html page structure example</em></p>\n<p>As you can see in the example above, there is a specific structure in every HTML document which everything is nested in elements starting with the <code>&#x3C;html>&#x3C;/html></code> element which represents the root of an HTML document, inside we have <code>&#x3C;head>&#x3C;/head></code> which is a container for metadata and <code>&#x3C;body>&#x3C;/body></code> area which contains all the content of an HTML document such as headings, paragraphs, images, hyperlinks, tables, lists, etc.</p>\n<h2>HTML Example</h2>\n<p>Firstly thing we want to put in every HTML document is the <code>&#x3C;!DOCTYPE html></code> which is an \"information\" to the browser about what document type to expect. The next thing is the <code>&#x3C;html></code> element like we saw in the HTML structure before. Inside the <code>&#x3C;head></code> we have the <code>&#x3C;title></code> element which is required and it defines the title of the HTML document.</p>\n<pre><code class=\"language-html\">&#x3C;!DOCTYPE html>                       &#x3C;!--Type of the document type to expect-->\n&#x3C;html>                                &#x3C;!--Root of an HTML document-->\n  &#x3C;head>                              &#x3C;!--Container for metadata-->\n    &#x3C;title>HTML for beginners&#x3C;/title> &#x3C;!--Defines the title of the document-->\n  &#x3C;/head>\n  &#x3C;body>                              &#x3C;!--Contains all the contents of an HTML document-->\n\n  &#x3C;/body>\n&#x3C;/html>\n</code></pre>\n<p><em>index.html - very basic HTML document</em></p>\n<blockquote>\n<p>On the right side there are comments which are: <!--Comment-->, comments are not shown in the browser, they are just visible to the developer.</p>\n</blockquote>\n<p><ad-incontent></ad-incontent></p>\n<h3>Headings</h3>\n<p>As you can see in the example, there are six different heading elements we can use: <code>&#x3C;h1></code>, <code>&#x3C;h2></code>, <code>&#x3C;h3></code>, <code>&#x3C;h4></code>, <code>&#x3C;h5></code>, <code>&#x3C;h6></code>, which <code>&#x3C;h1></code> defines the most important heading and <code>&#x3C;h6></code> defines the least important heading, also the size of each heading is not the same by default, you can later change the size with CSS.</p>\n<pre><code class=\"language-html\">&#x3C;!DOCTYPE html>\n&#x3C;html>\n  &#x3C;head>\n    &#x3C;title>HTML for beginners&#x3C;/title>\n  &#x3C;/head>\n  &#x3C;body>\n    &#x3C;!--Headings-->\n    &#x3C;h1>Heading One&#x3C;/h1>\n    &#x3C;h2>Heading Two&#x3C;/h2>\n    &#x3C;h3>Heading Three&#x3C;/h3>\n    &#x3C;h4>Heading Four&#x3C;/h4>\n    &#x3C;h5>Heading Five&#x3C;/h5>\n    &#x3C;h6>Heading Six&#x3C;/h6>\n  &#x3C;/body>\n&#x3C;/html>\n</code></pre>\n<blockquote>\n<p>Only use one <code>&#x3C;h1></code> per page, this should be the main heading/subject for the whole page. Also, you should not skip heading levels.</p>\n</blockquote>\n<h3>Paragraph</h3>\n<p>The paragraph in HTML is just the <code>&#x3C;p></code> element, we can use a paragraph to put a block of text inside of it. Every paragraph always starts on a new line, and browsers automatically add some white space before and after a paragraph.</p>\n<pre><code class=\"language-html\">&#x3C;!DOCTYPE html>\n&#x3C;html>\n  &#x3C;head>\n    &#x3C;title>HTML for beginners&#x3C;/title>\n  &#x3C;/head>\n  &#x3C;body>\n    &#x3C;!--Paragraph-->\n    &#x3C;p>\n      Some random short or long &#x3C;strong>paragraph&#x3C;/strong> text goes &#x3C;em>here&#x3C;/em> \n      if you want to learn more click &#x3C;a href=\"www.google.com\">here&#x3C;/a>\n    &#x3C;/p>\n  &#x3C;/body>\n&#x3C;/html>\n</code></pre>\n<blockquote>\n<p>Inline vs Block Elements - Inline elements do not start a new line and take only the necessary width, Block elements start on a new line and take the full width.</p>\n</blockquote>\n<p><ad-incontent></ad-incontent></p>\n<h3>Strong and Em</h3>\n<p>The first tags which we have seen were block elements, now let's see some of the inline elements. As you can see in the example we have a <code>&#x3C;strong></code> tag in the middle of the paragraph which is telling that the content inside the <code>&#x3C;strong></code> tag will be bold. Next is the <code>&#x3C;em></code> tag which is used for italic who is also inside the paragraph. </p>\n<h3>Link</h3>\n<p>If we want to link some content on our page we need to use the <code>&#x3C;a></code> tag. For the link element to work, we need to give it an attribute <code>href=\"some link\"</code> which is the link we want to use it, like in the example if we click on the link it will take us to the linked page. The <code>href</code> attribute can be an external or internal link. Another important attribute for a link is the <code>target=\"_blank\"</code> which will open the link in a new tab (usually you will use this if the link is an external site).</p>\n<blockquote>\n<p>HTML attributes provide additional information about HTML elements which are always specified in the start tag. Attributes are written as key/value.</p>\n</blockquote>\n<h3>Lists</h3>\n<p>In HTML there are also list elements, which are much important for displaying data. There are two types of list elements, ordered list <code>&#x3C;ol></code> and unordered list <code>&#x3C;ul></code>. Inside the lists, we need to have list items which are <code>&#x3C;li></code> elements, and inside of we will put the content. The difference between the ordered list and unordered list is that in the ordered list every item has a number, in the unordered list every item has a bullet point.</p>\n<pre><code class=\"language-html\">&#x3C;!DOCTYPE html>\n&#x3C;html>\n  &#x3C;head>\n    &#x3C;title>HTML for beginners&#x3C;/title>\n  &#x3C;/head>\n  &#x3C;body>\n    &#x3C;!--Lists-->\n    &#x3C;ol>\n      &#x3C;li>Item 1&#x3C;/li>\n      &#x3C;li>Item 2&#x3C;/li>\n      &#x3C;li>Item 3&#x3C;/li>\n    &#x3C;/ol>\n\n    &#x3C;ul>\n      &#x3C;li>Item 1&#x3C;/li>\n      &#x3C;li>Item 2&#x3C;/li>\n      &#x3C;li>Item 3&#x3C;/li>\n    &#x3C;/ul>\n  &#x3C;/body>\n&#x3C;/html>\n</code></pre>\n<h3>Br and Hr</h3>\n<p>There are <code>&#x3C;br></code> which is nothing more but just a line break, you can use <code>&#x3C;br></code> to separate some content (which can be also done with CSS). Also, there is a <code>&#x3C;hr></code> which is a horizontal rule that is a horizontal line. Both <code>&#x3C;br></code> and <code>&#x3C;hr></code> are self-closing tags.</p>\n<pre><code class=\"language-html\">&#x3C;!DOCTYPE html>\n&#x3C;html>\n  &#x3C;head>\n    &#x3C;title>HTML for beginners&#x3C;/title>\n  &#x3C;/head>\n  &#x3C;body>\n    &#x3C;br>\n    &#x3C;hr>\n  &#x3C;/body>\n&#x3C;/html>\n</code></pre>\n<h3>Form</h3>\n<p>Forms are an important part of a web page which will get some data from the user and send to the server, with HTML we are just looking for the form, we cannot add functionality. The form starts with the <code>&#x3C;form></code> element, and in most of the cases, the form will have an attribute <code>action=\"some file\"</code> which will submit the form to some page. Also there should be method attribute <code>method=\"POST\"</code> which in most of the cases will be post, which means we are doing a post request to the server, or simply we are sending some data to the server.</p>\n<pre><code class=\"language-html\">&#x3C;!DOCTYPE html>\n&#x3C;html>\n  &#x3C;head>\n    &#x3C;title>HTML for beginners&#x3C;/title>\n  &#x3C;/head>\n  &#x3C;body>\n    &#x3C;!--Forms-->\n    &#x3C;form action=\"submit.php\" method=\"POST\">\n      &#x3C;label>First Name&#x3C;/label>\n      &#x3C;input type=\"text\" name=\"first_name\">\n      &#x3C;input type=\"submit\" name=\"submit\" value=\"Submit\">\n    &#x3C;/form>\n\n  &#x3C;/body>\n&#x3C;/html>\n</code></pre>\n<blockquote>\n<p>There are other HTTP requests too like, GET, POST, PUT, DELETE, etc.</p>\n</blockquote>\n<p>Inside the form, we have a <code>&#x3C;label></code> element, which is nothing more than just a label for an input field below of it which is declared with the element <code>&#x3C;input></code>. The input element has a couple of attributes like <code>type=\"text\"</code> which sets the type of the input field, the next is the <code>name=\"first_name\"</code> is the value which we give to the server-side. Also, you can see that the input element doesn't have a closing tag because it is self-closing. Also, we can use input elements like a button to submit the form which is the last input element in our example. The submit element has a type, name, and value, the first two we already know about them the last one the value is the text of the button.</p>\n<p><ad-incontent></ad-incontent></p>\n<h3>Button</h3>\n<p>We can also have a button independent from the form, we can declare a button with the <code>&#x3C;button></code> tag. For a button to do something we need to use JavaScript, but in this tutorial, we are gonna focus just on HTML, inside the button element we put the text for the button.</p>\n<pre><code class=\"language-html\">&#x3C;!DOCTYPE html>\n&#x3C;html>\n  &#x3C;head>\n    &#x3C;title>HTML for beginners&#x3C;/title>\n  &#x3C;/head>\n  &#x3C;body>\n    &#x3C;!--Button-->\n    &#x3C;button>Submit&#x3C;/button>\n\n  &#x3C;/body>\n&#x3C;/html>\n</code></pre>\n<h3>Image</h3>\n<p>We can use images in HTML with the <code>&#x3C;img></code> element, the image element is also with a self-closing tag. To display an image in the image element, we need to give it a source attribute with the <code>src=\"image_path/url\"</code>, we can use images from local storage or we can use an image from the web. We can also set the width and height of an image with HTML.</p>\n<pre><code class=\"language-html\">&#x3C;!DOCTYPE html>\n&#x3C;html>\n  &#x3C;head>\n    &#x3C;title>HTML for beginners&#x3C;/title>\n  &#x3C;/head>\n  &#x3C;body>\n    &#x3C;!--Image-->\n    &#x3C;img src=\"path\" width=\"300\"/>\n\n  &#x3C;/body>\n&#x3C;/html>\n</code></pre>\n<h2>HTML5 Semantic Tags</h2>\n<p>With HTML5 we can enrich the semantic content of HTML documents, new page structure elements such as <main>, <section>, <article>, <header>, <footer>, <aside>, <nav>, and <figure> have been added. This allows the code to be much clear to both the developer and the browser.</p>\n<pre><code class=\"language-html\">&#x3C;!DOCTYPE html>\n&#x3C;html>\n  &#x3C;head>\n    &#x3C;title>HTML for beginners&#x3C;/title>\n  &#x3C;/head>\n  &#x3C;body>\n    &#x3C;header>&#x3C;!--header-->&#x3C;/header>\n    &#x3C;nav>&#x3C;!--navbar-->&#x3C;/nav>\n    &#x3C;main>&#x3C;!--main_content-->&#x3C;/main>\n    &#x3C;aside>&#x3C;!--sidebar-->&#x3C;/aside>\n    &#x3C;footer>&#x3C;!--footer-->&#x3C;/footer>\n  &#x3C;/body>\n&#x3C;/html>\n</code></pre>\n<p><em>html5 semantic example</em></p>\n<p><ad-incontent></ad-incontent></p>\n<p>You can find the full code below</p>\n<pre><code class=\"language-html\">&#x3C;!DOCTYPE html>\n&#x3C;html>\n  &#x3C;head>\n    &#x3C;title>HTML for beginners&#x3C;/title>\n  &#x3C;/head>\n  &#x3C;body>\n    &#x3C;header>&#x3C;!--header-->&#x3C;/header>\n    &#x3C;nav>&#x3C;!--navbar-->&#x3C;/nav>\n    &#x3C;main>\n      &#x3C;!--Headings-->\n      &#x3C;h1>Heading One&#x3C;/h1>\n      &#x3C;h2>Heading Two&#x3C;/h2>\n      &#x3C;h3>Heading Three&#x3C;/h3>\n      &#x3C;h4>Heading Four&#x3C;/h4>\n      &#x3C;h5>Heading Five&#x3C;/h5>\n      &#x3C;h6>Heading Six&#x3C;/h6>\n\n      &#x3C;!--Paragraph-->\n      &#x3C;p>\n        Some random short or long &#x3C;strong>paragraph&#x3C;/strong> text goes &#x3C;em>here&#x3C;/em> \n        if you want to learn more click &#x3C;a href=\"www.google.com\">here&#x3C;/a>\n      &#x3C;/p>\n\n      &#x3C;!--Lists-->\n      &#x3C;ol>\n        &#x3C;li>Item 1&#x3C;/li>\n        &#x3C;li>Item 2&#x3C;/li>\n        &#x3C;li>Item 3&#x3C;/li>\n      &#x3C;/ol>\n\n      &#x3C;ul>\n        &#x3C;li>Item 1&#x3C;/li>\n        &#x3C;li>Item 2&#x3C;/li>\n        &#x3C;li>Item 3&#x3C;/li>\n      &#x3C;/ul>\n\n      &#x3C;br>\n      &#x3C;hr>\n\n      &#x3C;!--Forms-->\n      &#x3C;form action=\"submit.php\" method=\"POST\">\n        &#x3C;label>First Name&#x3C;/label>\n        &#x3C;input type=\"text\" name=\"first_name\">\n        &#x3C;input type=\"submit\" name=\"submit\" value=\"Submit\">\n      &#x3C;/form>\n\n      &#x3C;!--Button-->\n      &#x3C;button>Submit&#x3C;/button>\n\n      &#x3C;!--Image-->\n      &#x3C;img src=\"path\" width=\"300\"/>\n    &#x3C;/main>\n    &#x3C;aside>&#x3C;!--sidebar-->&#x3C;/aside>\n\n    &#x3C;footer>&#x3C;!--footer-->&#x3C;/footer>\n  &#x3C;/body>\n&#x3C;/html>\n</code></pre>\n<p><em>index.html</em></p>","frontmatter":{"path":"/html-for-beginners/","date":"2020-06-16T11:33:49.619Z","title":"HTML for Complete Beginners","author":"Aleksandar Vasilevski","image":"/assets/cover/html.png","category":"HTML","tags":"#html #webdev","featured":false}}},{"node":{"id":"64bc92dd-753e-553f-b1ca-196cecacd40f","html":"<p><img src=\"/assets/cover/web-development-courses.jpg\" alt=\"javascript-logo\"></p>\n<p>Web developers today are one of the most in-demand and very well paid. With the skill set of web developers, you can work in a company, as freelance or even you can make your web application to make money.</p>\n<p>There are Front-end, Back-end, and best of both worlds Full-stack web developers, a full-stack web developer has basic skills across a lot of platforms and technologies as well as deeper knowledge and specialization in some of those. Some of the skills a web developer should have are:</p>\n<ul>\n<li><strong>Front End</strong> – HTML, CSS, JavaScript, JQuery, Bootstrap</li>\n<li><strong>Back End</strong> – PHP, Python, Ruby on Rails, NodeJS, Java</li>\n<li><strong>Databases</strong> – MySQL, MongoDB</li>\n</ul>\n<p><em>Want to become a web developer? Here’s a list of best courses and tutorials that will help you learn the right skills to start your career as a web developer and advance yourself as a full-stack web developer.</em></p>\n<h2>The Web Developer Bootcamp</h2>\n<p><em>The only course you need to learn web development - HTML, CSS, JS, Node, and More!</em></p>\n<p><a href=\"https://click.linksynergy.com/link?id=LFcSQV4ezac&offerid=507388.625204&type=2&murl=https%3A%2F%2Fwww.udemy.com%2Fcourse%2Fthe-web-developer-bootcamp%2F\"><IMG border=0 src=\"https://img-a.udemycdn.com/course/480x270/625204_436a_2.jpg\" ></a><IMG border=0 width=1 height=1 src=\"https://ad.linksynergy.com/fs-bin/show?id=LFcSQV4ezac&bids=507388.625204&type=2&subid=0\" ></p>\n<p><strong>The Web Developer Bootcamp</strong> is a course by Colt Steele. This course can be a single web development course that you will ever need it because it covers almost everything from front-end to back-end and databases. The Web Developer Bootcamp has been enrolled by more than 500,000 students and it is very highly rated with reviews. This course is very friendly for beginners that take step by step to give students a good foundation in modern web development. The course covers a wide range of tools and technologies including HTML5, CSS3, JavaScript, Bootstrap 4, SemanticUI, DOM Manipulation, jQuery, Unix(Command Line) commands, NodeJS, NPM, ExpressJS, REST, MongoDB, Database Associations, Authentication, PassportJS, and Authorization.</p>\n<p><strong>Whether you’re a beginner or someone who needs a refresher on the basics or someone looking to learn new skills in web development, this course works perfectly for all.</strong></p>\n<p><a style=\"background-color:#ff7a59; color:#fff; padding:10px 20px; border-radius:4px;\" href=\"https://click.linksynergy.com/link?id=LFcSQV4ezac&offerid=507388.625204&type=2&murl=https%3A%2F%2Fwww.udemy.com%2Fcourse%2Fthe-web-developer-bootcamp%2F\">Start The Web Developer Bootcamp</a><IMG border=0 width=1 height=1 src=\"https://ad.linksynergy.com/fs-bin/show?id=LFcSQV4ezac&bids=507388.625204&type=2&subid=0\" ></p>\n<br>\n<h2>The Complete Web Developer Course 2.0</h2>\n<p><em>Learn Web Development by building 25 websites and mobile apps using HTML, CSS, Javascript, PHP, Python, MySQL &#x26; more!</em></p>\n<p><a href=\"https://click.linksynergy.com/link?id=LFcSQV4ezac&offerid=507388.764164&type=2&murl=https%3A%2F%2Fwww.udemy.com%2Fcourse%2Fthe-complete-web-developer-course-2%2F\"><IMG border=0 src=\"https://img-a.udemycdn.com/course/480x270/764164_de03_2.jpg\" ></a><IMG border=0 width=1 height=1 src=\"https://ad.linksynergy.com/fs-bin/show?id=LFcSQV4ezac&bids=507388.764164&type=2&subid=0\" ></p>\n<p><strong>The Complete Web Developer Course 2.0</strong> again a very good course which will introduce to the web development. The Complete Web Developer Course 2.0 has been enrolled by 250,000 students. This course is great for beginners, you will get hands-on experience with building real projects with a wide range of technologies like HTML, CSS, Javascript, PHP, Python, MySQL.</p>\n<p><strong>You will learn how to build your responsive websites with basic technologies like HTML, CSS, and JavaScript, also more advanced techniques such as jQuery, PHP, Python, MySQL and Twitter Bootstrap.</strong></p>\n<p><a style=\"background-color:#ff7a59; color:#fff; padding:10px 20px; border-radius:4px;\" href=\"https://click.linksynergy.com/link?id=LFcSQV4ezac&offerid=507388.764164&type=2&murl=https%3A%2F%2Fwww.udemy.com%2Fcourse%2Fthe-complete-web-developer-course-2%2F\">Start The Complete Web Developer Course 2.0</a><IMG border=0 width=1 height=1 src=\"https://ad.linksynergy.com/fs-bin/show?id=LFcSQV4ezac&bids=507388.764164&type=2&subid=0\" ></p>\n<br>\n<h2>The Advanced Web Developer Bootcamp</h2>\n<p><em>Learn React 16, Redux, D3, ES2015, Testing, CSS Flexbox, Animations, SVG, AJAX, and more!</em></p>\n<p><a href=\"https://click.linksynergy.com/link?id=LFcSQV4ezac&offerid=507388.1218586&type=2&murl=https%3A%2F%2Fwww.udemy.com%2Fcourse%2Fthe-advanced-web-developer-bootcamp%2F\"><IMG border=0 src=\"https://img-a.udemycdn.com/course/480x270/1218586_9f86.jpg\" ></a><IMG border=0 width=1 height=1 src=\"https://ad.linksynergy.com/fs-bin/show?id=LFcSQV4ezac&bids=507388.1218586&type=2&subid=0\" ></p>\n<p><strong>The Advanced Web Developer Bootcamp</strong> is the next part of the first course by Colt Steele. This course is also highly rated with over 60,000 enrolled students. Starting this course will teach you the advanced web development technologies like React, Redux, D3, Testing, CSS Flexbox, Animations, SVG, and Ajax. As you learn, with this course you will develop real web applications using the latest state-of-the-art technologies. There are over ten projects with a lot of code challenges to master the material.</p>\n<p><strong>This course is perfect for web developers who have a basic understanding of HTML, CSS, and JavaScript and want to explore more advanced concepts and technologies to become more successful in their career</strong></p>\n<p><a style=\"background-color:#ff7a59; color:#fff; padding:10px 20px; border-radius:4px;\" href=\"https://click.linksynergy.com/link?id=LFcSQV4ezac&offerid=507388.1218586&type=2&murl=https%3A%2F%2Fwww.udemy.com%2Fcourse%2Fthe-advanced-web-developer-bootcamp%2F\">Start The Advanced Web Developer Bootcamp</a><IMG border=0 width=1 height=1 src=\"https://ad.linksynergy.com/fs-bin/show?id=LFcSQV4ezac&bids=507388.1218586&type=2&subid=0\" ></p>\n<br>\n<h2>The Complete JavaScript Course 2020: Build Real Projects!</h2>\n<p><em>Master JavaScript with the most complete course! Projects, challenges, quizzes, JavaScript ES6+, OOP, AJAX, Webpack</em></p>\n<p><a href=\"https://click.linksynergy.com/link?id=LFcSQV4ezac&offerid=507388.851712&type=2&murl=https%3A%2F%2Fwww.udemy.com%2Fcourse%2Fthe-complete-javascript-course%2F\"><IMG border=0 src=\"https://img-a.udemycdn.com/course/480x270/851712_fc61_5.jpg\" ></a><IMG border=0 width=1 height=1 src=\"https://ad.linksynergy.com/fs-bin/show?id=LFcSQV4ezac&bids=507388.851712&type=2&subid=0\" ></p>\n<p><strong>The Complete JavaScript Course 2020: Build Real Projects!</strong> is a course focused on learning JavaScript which is one of the most important parts of every Web Developer as you can use JavaScript today for both front-end and back-end development. This course is a bestseller with over 300,000 enrolled students and offers a lot of projects, challenges, quizzes which will help you in the learning process.</p>\n<p><strong>This course is perfect for everyone who wants to dive deeper and master JavaScript with a lot of modern tools like ES6+, OOP, AJAX, Webpack</strong></p>\n<p><a style=\"background-color:#ff7a59; color:#fff; padding:10px 20px; border-radius:4px;\" href=\"https://click.linksynergy.com/link?id=LFcSQV4ezac&offerid=507388.851712&type=2&murl=https%3A%2F%2Fwww.udemy.com%2Fcourse%2Fthe-complete-javascript-course%2F\">Start The Complete JavaScript Course 2020: Build Real Projects!</a><IMG border=0 width=1 height=1 src=\"https://ad.linksynergy.com/fs-bin/show?id=LFcSQV4ezac&bids=507388.851712&type=2&subid=0\" ></p>\n<br>\n<h2>Conclusion</h2>\n<p>All four courses are great for learning Web development in depth. You don’t need to go through all of them, but I suggest you start with the first one if you are a beginner, happy learning!</p>","frontmatter":{"path":"/best-web-development-courses/","date":"2020-06-11T11:20:49.619Z","title":"Best Web Development Courses for Beginners (Updated 2021)","author":"Aleksandar Vasilevski","image":"/assets/cover/web-development-courses.jpg","category":"Courses","tags":"#html #css #js #javascript #nodejs #php #python #webdev","featured":false}}},{"node":{"id":"7c22b784-5174-550b-874a-0a304e603df0","html":"<p><img src=\"/assets/cover/javascript.png\" alt=\"javascript-logo\"></p>\n<p>Dealing with arrays is everyday work for every developer. In this article, we are going to see 6 different approaches to how you can iterate through in Javascript.</p>\n<h2>for Loop</h2>\n<p>The for loop statement has three expressions:</p>\n<ol>\n<li><strong>Initialization</strong> - initialize the loop variable with a value and it is executed once</li>\n<li><strong>Condition</strong> - defines the loop stop condition</li>\n<li><strong>Update</strong> - executed every time after the code block of the loop has been executed.</li>\n</ol>\n<pre><code class=\"language-javascript\">for (initialization; condition; update statement) {\n    // code block to be executed\n}\n</code></pre>\n<p><em>for loop syntax</em></p>\n<p>Example of for-loop:</p>\n<pre><code class=\"language-javascript\">var array = [\n    {id: 0, name: 'John', age: 20},\n    {id: 1, name: 'Jane', age: 22},\n    {id: 2, name: 'Bob', age: 24},\n    {id: 3, name: 'Ana', age: 26},\n];\n\nfor(let i = 0; i &#x3C; array.length; i++){\n    console.log(array[i].name);\n}\n\n/*\nOutput:\n    John\n    Jane\n    Bob\n    Ana\n*/\n</code></pre>\n<blockquote>\n<p>A break statement can be used to stop the loop at any time.</p>\n</blockquote>\n<p><ad-incontent></ad-incontent></p>\n<h2>while Loop</h2>\n<p>The while loop statement has one expression:</p>\n<ol>\n<li><strong>Condition</strong> - defines the loop stop condition</li>\n</ol>\n<pre><code class=\"language-javascript\">while (condition) {\n    // code block to be executed\n}\n</code></pre>\n<p><em>while loop syntax</em></p>\n<p>Example of while-loop:</p>\n<pre><code class=\"language-javascript\">var array = [\n    {id: 0, name: 'John', age: 20},\n    {id: 1, name: 'Jane', age: 22},\n    {id: 2, name: 'Bob', age: 24},\n    {id: 3, name: 'Ana', age: 26},\n];\n\nvar i = 0;\nwhile(i &#x3C; array.length) {\n    console.log(array[i].name)\n    i++\n}\n\n/*\nOutput:\n    John\n    Jane\n    Bob\n    Ana\n*/\n</code></pre>\n<h2>do/while Loop</h2>\n<p>The do/while loop statement has one expressions:</p>\n<ol>\n<li><strong>Condition</strong> - defines the loop stop condition</li>\n</ol>\n<pre><code class=\"language-javascript\">do {\n    // code block to be executed\n} while (condition)\n</code></pre>\n<p><em>do/while loop syntax</em></p>\n<p>Example of do/while loop:</p>\n<pre><code class=\"language-javascript\">var array = [\n    {id: 0, name: 'John', age: 20},\n    {id: 1, name: 'Jane', age: 22},\n    {id: 2, name: 'Bob', age: 24},\n    {id: 3, name: 'Ana', age: 26},\n];\n\nvar i = 0;\ndo {\n    console.log(array[i].name)\n    i++\n} while(i &#x3C; array.length)\n  \n/*\nOutput:\n    John\n    Jane\n    Bob\n    Ana\n*/\n</code></pre>\n<p><ad-incontent></ad-incontent></p>\n<h2>for/of Loop</h2>\n<p>The for/of loop statement has two expressions:</p>\n<ol>\n<li><strong>Iterator</strong> - refers to the array who will be iterated</li>\n<li><strong>Variable</strong> - The value of the next iteration stored in a variable (which has to be declared with either const, let, or var to hold the value)</li>\n</ol>\n<pre><code class=\"language-javascript\">for (value of iterator) {\n    // code block to be executed\n}\n</code></pre>\n<p><em>for/of loop syntax</em></p>\n<p>Example of for/off loop:</p>\n<pre><code class=\"language-javascript\">var array = [\n    {id: 0, name: 'John', age: 20},\n    {id: 1, name: 'Jane', age: 22},\n    {id: 2, name: 'Bob', age: 24},\n    {id: 3, name: 'Ana', age: 26},\n];\n\nfor (let index of array) {\n    console.log(index.name)\n}\n\n/*\nOutput:\n    John\n    Jane\n    Bob\n    Ana\n*/\n</code></pre>\n<h2>forEach()</h2>\n<p>The forEach() is a method of the array that uses a callback function to include any custom logic to the iteration. The forEach() will execute the provided callback function once for each array element.</p>\n<p>The callback function takes up 3 arguments:</p>\n<ol>\n<li><strong>currentValue</strong> - value of the current element</li>\n<li><strong>index (optional)</strong> - array index of the current element</li>\n<li><strong>array (optional)</strong> - entire array object</li>\n</ol>\n<p>The <strong>thisArg (optional)</strong> - value for the callback function which will be used as its this value.</p>\n<pre><code class=\"language-javascript\">array.forEach(callback(currentValue [, index [, array]])[, thisArg]);\n</code></pre>\n<p><em>forEach() loop syntax</em></p>\n<p>Example of forEach():</p>\n<pre><code class=\"language-javascript\">var array = [\n    {id: 0, name: 'John', age: 20},\n    {id: 1, name: 'Jane', age: 22},\n    {id: 2, name: 'Bob', age: 24},\n    {id: 3, name: 'Ana', age: 26},\n];\n\narray.forEach(function(profile, index, myArray) {\n    console.log(`Index: ${index}, Name: ${profile.name}`);\n});\n\n/*\nOutput:\n    John\n    Jane\n    Bob\n    Ana\n*/\n</code></pre>\n<p><ad-incontent></ad-incontent></p>\n<h2>map()</h2>\n<p>The map() method is very similar to the forEach() method as it will also execute the provided callback function for each element in the array. The difference between the two is that the map() method creates and returns a new array based on the result of the provided callback function.</p>\n<p>The callback function takes up 3 arguments:</p>\n<ol>\n<li><strong>currentValue</strong> - value of the current element</li>\n<li><strong>index (optional)</strong> - array index of the current element</li>\n<li><strong>array (optional)</strong> - entire array object</li>\n</ol>\n<p>The <strong>thisArg (optional)</strong> - value for the callback function which will be used as its this value.</p>\n<pre><code class=\"language-javascript\">var new_array = array.map(function callback(currentValue[, index[, array]]) {\n    // Return element for new_array\n}[, thisArg])\n</code></pre>\n<p><em>map() loop syntax</em></p>\n<p>Example of map():</p>\n<pre><code class=\"language-javascript\">var array = [\n    {id: 0, name: 'John', age: 20},\n    {id: 1, name: 'Jane', age: 22},\n    {id: 2, name: 'Bob', age: 24},\n    {id: 3, name: 'Ana', age: 26},\n];\n\nvar newArray = myArray.map(function(profile, index, myArr) {\n    var newProfile = {\n        'id': index,\n        'name': profile.firstName,\n        'age': profile.age\n    }\n\n    return newProfile\n})\n\nnewArray.forEach(function(profile, index, myArr) {\n    console.log(profile.fullName)\n});\n\n/*\nOutput:\n    John\n    Jane\n    Bob\n    Ana\n*/\n</code></pre>\n<blockquote>\n<p>If you want to learn more about both methods forEach() and map(), you can check <a href=\"/javascript-map-vs-foreach/\"><em>JavaScript Map vs ForEach Method</em></a></p>\n</blockquote>","frontmatter":{"path":"/ways-to-loop-through-an-array-in-javascript/","date":"2020-06-10T11:10:49.619Z","title":"6 Ways to Loop Through an Array in JavaScript","author":"Aleksandar Vasilevski","image":"/assets/cover/javascript.png","category":"JavaScript","tags":"#js #javascript #array","featured":false}}},{"node":{"id":"a2e4e162-13da-51d8-a64d-73c6a2df23dc","html":"<p><img src=\"/assets/cover/create-react-app-from-scratch-part-5.png\" alt=\"create-react-app-part-5\"></p>\n<p>This article is part of the ReactJS series, you can find the previous part on the following link: <a href=\"https://www.codespot.org/create-react-app-from-scratch-part-4/\" style=\"font-weight:bold; text-transform:uppercase; color:#ff7a59;\">Create React App From Scratch Part 4: Styling Components</a>.</p>\n<h2>HTTP Requests with Axios</h2>\n<p>Almost every web application build with React will need to get some data from a server, because as you know React is just the frontend. Most of the time for making the data requests from the server we are using HTTP requests, there are other methods too but in this part, we will focus on HTTP requests. In single-page applications we are not getting HTML pages when we are sending requests to the server, instead, we will get JSON data, we can send JSON data to the server too. The server which will be responding to our requests is typically Restful API. In this tutorial, we will make the HTTP requests with Axios. Axios is a promise-based HTTP client for the browser and also for Node.js. If you want to read more in detail about Axios you can get more info at <a href=\"/axios-http-client/\"><em>Guide to Axios js Http Client</em></a>.</p>\n<blockquote>\n<p>There are other popular libraries for making HTTP requests as jQuery AJAX, window.fetch, etc.</p>\n</blockquote>\n<p><ad-incontent></ad-incontent></p>\n<p>In the previous parts, we have created a basic react app, now it is time to get real data instead of the dummy data. Firstly thing what we need to do is to create the HTTP requests, but where are we gonna put them? React have a lifecycle in the future we will see how this lifecycle work in detail, now we will use <code>ComponentDidMount()</code> which is the place where we will make HTTP requests. Firstly we need to install Axios with <code>npm install axios</code>, then in the <code>CryptoCurrencies</code> container, on the top, we need to import Axios, and to create <code>ComponentDidMount()</code>.</p>\n<blockquote>\n<p>For our request to return a date we will need some Rest API, I will be using CoinGecko, it is free with great documentation, you can find more info on\n<a href=\"https://www.coingecko.com/en/api#explore-api\"><em>coingecko.com</em></a>.</p>\n</blockquote>\n<p>Axios by default uses promises, in our example, we will use async/await, you can read more about it at <a href=\"/async-javascript-part-3-async-await/\"><em>Async JavaScript Part 3: Async/Await</em></a>. lets see the example:</p>\n<pre><code class=\"language-javascript\">import React, {Component} from 'react';\nimport Cryptocurrency from '../../components/Cryptocurrency/Cryptocurrency'\nimport {Container} from 'react-bootstrap'\nimport axios from 'axios'\n\nclass CryptoCurrencies extends Component {\n\n  state = {\n    coins: []\n  }\n\n  async componentDidMount(){\n    try{\n      let response = await axios.get('https://api.coingecko.com/api/v3/coins/')\n      this.setState({coins: response.data})\n    }catch(err){\n      console.log(err);\n    }\n  }\n\n  render(){\n    const cryptocurrencies = this.state.coins.map(coin => {\n      return &#x3C;Cryptocurrency key={coin.id} name={coin.name} symbol={coin.symbol} price={coin.market_data.current_price.usd}/>\n    })\n    return(\n      &#x3C;Container>\n        {cryptocurrencies}\n      &#x3C;/Container>\n    );\n  }\n}\n\nexport default CryptoCurrencies;\n</code></pre>\n<p><em>CryptoCurrencies.js</em></p>\n<p>As you can see we are getting the API response from the coingecko.com, then we are setting the response to the state. On the bottom firstly we are mapping every cryptocurrency to the Cryptocurrency component and we are outputting the list in the container.</p>\n<p><ad-incontent></ad-incontent></p>\n<h2>Part Overview</h2>\n<p>In this part, we have seen basics about how we can fetch data in the React components with Axios, and we have outputted that data instead of the old dummy data. HTTP requests are very important because almost any React application needs some data to display or send some data to the server. </p>\n<p>If you are interested to learn React much deeper, I recommend you to read this book: </p>\n<p><a href=\"https://www.amazon.com/gp/product/B077HJFCQX/ref=as_li_tl?ie=UTF8&camp=1789&creative=9325&creativeASIN=B077HJFCQX&linkCode=as2&tag=aleksandarvas-20&linkId=6c518448e9ae3041011a1dfc8cea8e00\" style=\"font-weight:bold; text-decoration:underline; color:#ff7a59;\">The Road to learn React: Your journey to master plain yet pragmatic React.js</a></p>\n<p>If you prefer a video course, I highly recommend you to take a look at this course on Udemy:</p>\n<p><a href=\"https://click.linksynergy.com/link?id=LFcSQV4ezac&offerid=507388.1362070&type=2&murl=https%3A%2F%2Fwww.udemy.com%2Fcourse%2Freact-the-complete-guide-incl-redux%2F\"><IMG border=0 src=\"https://i.udemycdn.com/course/480x270/1362070_b9a1_2.jpg\" ><div >React - The Complete Guide (incl Hooks, React Router, Redux)</div></a><IMG border=0 width=1 height=1 src=\"https://ad.linksynergy.com/fs-bin/show?id=LFcSQV4ezac&bids=507388.1362070&type=2&subid=0\" ></p>\n<p>The code from the course is available on GitHub: <a href=\"https://github.com/AleksandarVasilevski/create-react-app-from-scratch\"><strong>Create React App From Scratch</strong></a> on the branch: 05-http-requests.</p>\n<p>You can find the next part of the series here: <a style=\"font-weight:bold; text-transform:uppercase; color:#ff7a59;\">Upcoming!</a></p>","frontmatter":{"path":"/create-react-app-from-scratch-part-5/","date":"2020-06-09T10:30:49.619Z","title":"Create React App From Scratch Part 5: Http Requests","author":"Aleksandar Vasilevski","image":"/assets/cover/create-react-app-from-scratch-part-5.png","category":"React","tags":"#react #js #javascript #createReactAppFromScratch #http #request","featured":false}}},{"node":{"id":"ea4cc04e-512a-56dc-a821-a5404a09ae35","html":"<p><img src=\"/assets/cover/deno.png\" alt=\"deno-logo\"></p>\n<h2>What is Deno?</h2>\n<p>Deno is a runtime for JavaScript and TypeScript based on the JavaScript V8 engine the same as the Node.js, and it is created by the same person as the Node.js, Ryan Dahl. Deno was announced by Dahl in 2018 during his talk \"10 Things I Regret About Node.js\". Deno aims to be a productive environment for the modern programming, like Node.js it is an event-driven architecture, with a set of non-blocking IO utilities, along with their blocking versions. Deno is used mostly for creating web servers. You can check the talk by Ryan Dahl on Youtube on the link below:</p>\n<p><a href=\"https://www.youtube.com/watch?v=M3BM9TB-8yA\"><img src=\"https://img.youtube.com/vi/YOUTUBE_VIDEO_ID_HERE/0.jpg\" alt=\"deno\"></a>\n<em>10 Things I Regret About Node.js - Ryan Dahl - JSConf EU</em></p>\n<h2>Deno Web Server Example</h2>\n<p>Let's see how does Deno look in some very simple code samples:</p>\n<pre><code class=\"language-typescript\">import {serve} from 'https://deno.land/std@0.50.0/http/server.ts'\nconst s = serve({ port: 8000 });\nconsole.log(\"http://localhost:8000/\");\nfor await (const req of s) {\n  req.respond({ body: \"Hello World\\n\" });\n} \n</code></pre>\n<p>As you can see we can use TypeScript out of the box with Deno (you can still use JavaScript), next interesting thing is that we can use the import syntax (if you worked with React or some modern JavaScript you should be familiar with it), and as we can see we don't need to install npm modules to import them, instead of with Deno we can import from URL. On the 4'th line, we can also see more modern JavaScript features that Deno is using like promises or async iterable (this is a for loop that goes through an infinite array of incoming events).</p>\n<p>You can find more info and documentation about Deno on <a href=\"https://deno.land/\"><em>Deno.Land</em></a></p>\n<p><ad-incontent></ad-incontent></p>\n<h2>Deno Comparison with Node.js</h2>\n<p>As we said Deno and Node.js are both runtimes that are built on the V8 engine, the same engine used for Google Chrome. Both Deno and Node.js have internal event loops and provide a command line for running scripts. Deno is different from Node.js in the following aspects:</p>\n<ul>\n<li>Uses ES Module as the default module system, instead of CommonJS.</li>\n<li>Uses URLs for loading local or remote dependencies, similar to browsers.</li>\n<li>Includes a built-in package manager for resource fetching, thus no need for NPM.</li>\n<li>Supports TypeScript out of the box, using a snapshotted TypeScript compiler with caching mechanisms.</li>\n<li>Aims better compatibility with browsers with a wide range of Web API.</li>\n<li>Allows a control to file system and network access in order to run sandboxed code.</li>\n<li>Redesigns API to utilize Promises, ES6, and TypeScript features.</li>\n<li>Minimizes core API size, while providing a large standard library with no external dependencies.</li>\n<li>Using message passing channels for invoking privileged system APIs and using bindings.</li>\n</ul>\n<p><em>Source:</em> <a href=\"**https://en.wikipedia.org/wiki/Deno_(software)**\"><em>Wikipedia</em></a></p>\n<h2>Conclusion</h2>\n<p>Will Deno replace Node.js? Deno is a replacement for Node.js, BUT! not in the sense that you should start learning it and using it right away, instead you could look at Deno because it might do the same thing as Node.js but on a better way. Deno is still in the early stages of development, and Node.js is used in many projects out there, this means that Node.js is not going out of the game anytime soon.</p>","frontmatter":{"path":"/what-is-deno-and-will-it-replace-nodejs/","date":"2020-05-20T11:50:00.619Z","title":"What is Deno and Will it replace Node.js?","author":"Aleksandar Vasilevski","image":"/assets/cover/deno.png","category":"Deno","tags":"#deno #javascript #typescript","featured":false}}},{"node":{"id":"542df460-a321-5380-8ffb-d7b1049b92fb","html":"<p><img src=\"/assets/cover/javascript.png\" alt=\"javascript\"></p>\n<p>Before the ES6 was released, <code>var</code> was the only feature for declaring variables in Javascript. When the ES6 was released, one of the most interesting features was the addition of <code>let</code> and <code>const</code> for variable declarations. In this article we will see the difference between <code>var</code>, <code>let</code> and <code>const</code>.</p>\n<h2>VAR</h2>\n<p>The <code>var</code> declaration is the oldest of all and was used before the ES6 was released. There are associated issues with <code>var</code> declarations though. That's why new variable declarations were necessary. </p>\n<h3>Scope of var</h3>\n<p>The <code>var</code> declarations can be globally or locally scoped. If the <code>var</code> is declared outside a function it is globally scoped. This means that any <code>var</code> variables declared globally are available for use in the whole window. If the <code>var</code> is declared inside a function it is function scoped. This means that it is available and can be accessed only within that function. Let's see a simple example below.</p>\n<pre><code class=\"language-javascript\">var foo = \"foo\";\n\nfunction dummy(){\n  var bar = \"bar\";\n}\n</code></pre>\n<p>In the example above <code>foo</code> is globally scoped because it exists outside a function, while <code>bar</code> is function scoped. This means we cannot access the <code>bar</code> variable outside of our <code>dummy</code> function.</p>\n<h3>Hoisting of var</h3>\n<p>In JavaScript, hoisting is a mechanism where variables and function declarations are moved to the top of their scope before the code is executed. This means if we do:</p>\n<pre><code class=\"language-javascript\">console.log(foo);\nvar foo = \"foo\";\n</code></pre>\n<p>It will be interpreted like this</p>\n<pre><code class=\"language-javascript\">var foo;\nconsole.log(foo); //foo is undefined\nfoo = \"foo\";\n</code></pre>\n<p>As we can see var variables are hoisted to the top of its scope and initialized with a value of undefined.</p>\n<h3>Problem with var</h3>\n<p>If we are using var declarations everywhere we can start getting problems and bugs with our code. Let's see an example of var issues below.</p>\n<pre><code class=\"language-javascript\">var foo = \"bar is smaller\";\nvar bar = 5;\n\nif(bar > 3){\n  var foo = \"bar is bigger\";\n}\n\nconsole.log(foo); //bar is bigger\n</code></pre>\n<p>This is not a problem if you want foo to be redefined, but it becomes a problem when you do not realize that a variable foo has already been defined before. This might cause a lot of bugs in the code. This is why the let and const are necessary for some situations.</p>\n<p><ad-incontent></ad-incontent></p>\n<h2>LET</h2>\n<p>The <code>let</code> declaration is the preferred way for variable declaration after the ES6 was released, It is considered as an improvement to the <code>var</code> declarations.</p>\n<h3>Scope of let</h3>\n<p>The <code>let</code> declaration is block scoped (block is a piece of code encapsulated with \"{}\") this means a variable declared in a block with the let is only available for use within that block. Let's see an example about the <code>let</code>.</p>\n<pre><code class=\"language-javascript\">let foo = \"bar is smaller\";\nlet bar = 5;\n\nif(bar > 3){\n  let foo = \"bar is bigger\";\n  console.log(foo); //bar is bigger\n}\n\nconsole.log(foo); //bar is smaller\n</code></pre>\n<p>We can see that using foo outside its block its not updated from the block. This is because both instances of foo are treated as different variables since they have different scopes. If we want to update let like var we must do that inside its scope. Because of this, let is a better choice than var. When using let, you won't mess up if you have used a name for a variable before as a variable exists only within its scope.</p>\n<h3>Hoisting of let</h3>\n<p>Same as <code>var</code>, <code>let</code> variable declarations are hoisted on top, the difference is that with var is initialized as undefined, the let is not initialized. So if you try to access it you'll get a Reference Error.</p>\n<p><ad-incontent></ad-incontent></p>\n<h2>CONST</h2>\n<p>The <code>const</code> declaration is very similar to <code>let</code> and as the name const says they maintain constant values.</p>\n<h3>Scope of const</h3>\n<p>Same as let declarations, const declarations are block-scoped and can only be accessed within the block it was declared. The biggest difference is that they cannot be updated or re-declared, this means the value remains the same with the scope. Also every const declaration, therefore, must be initialized at the time of declaration.</p>\n<pre><code class=\"language-javascript\">const foo = \"foo\";\nfoo = \"bar\";//error : Assignment to constant variable. \n</code></pre>\n<h3>Hoisting of const</h3>\n<p>The <code>const</code> declarations here are the same as let also. they are hoisted to the top but are not initialized.</p>\n<blockquote>\n<p>If you want to learn more in-depth about scope in Javascript, I highly recommend you to check this book: <a href=\"https://www.amazon.com/gp/product/1449335586/ref=as_li_tl?ie=UTF8&camp=1789&creative=9325&creativeASIN=1449335586&linkCode=as2&tag=aleksandarvas-20&linkId=ed79defe056ce1e2a0f38da21cf91c43\" style=\"font-weight:bold; color:#00a4ccff; text-decoration: underline;\">You Don't Know JS: Scope &#x26; Closures</a></p>\n</blockquote>","frontmatter":{"path":"/the-difference-between-var-let-and-const-in-javascript/","date":"2020-05-05T12:10:00.619Z","title":"The Difference Between var, let and const in JavaScript","author":"Aleksandar Vasilevski","image":"/assets/cover/javascript.png","category":"JavaScript","tags":"#javascript","featured":false}}},{"node":{"id":"eec108c6-9d71-56a1-8e25-8d28de8da85f","html":"<p><img src=\"/assets/cover/puzzle.jpg\" alt=\"rubik-cube\"></p>\n<h2>The Binary Search Algorithm</h2>\n<p><img style=\"float: right\" src=\"/assets/samples/binary-search-1.png\"></img>\nThe binary search algorithm is a divide and conquer type algorithm, the idea behind the binary search is that the first comparison is done in the middle of the list if the item that we are searching for is it in the middle, the searching is complete, if the item we are searching is smaller then the item in the middle we are going to repeat the process on the left half of the list, or if the item we are searching is bigger then the item in the middle, we are going to search on the right side of the list. The initial size of searching is the entire list, but on each round, the size shrinks so the new size is half as big as the previous size. An important thing to remember about the binary search is that this type of search to work the list must be sorted in order. If the items in the list are not sorted, the most efficient search to be used is a <a href=\"https://www.codespot.org/algorithms-and-data-structures-linear-search/\"><em>linear search</em></a>.</p>\n<blockquote>\n<p>The divide-and-conquer paradigm is often used to find an optimal solution to a problem. The basic idea behind divide-and-conquer is to decompose a given problem into two or more similar, but simpler, subproblems, to solve them in turn, and to compose their solutions to solve the given problem.</p>\n</blockquote>\n<h2>Implementing Binary Search Algorithm</h2>\n<p>A binary search algorithm is not too complex for implementation, and it is very practical if the list is sorted (as we said before if the list is not sorted the binary search algorithm will not work!). Let's see an example of a binary search algorithm in Python.</p>\n<pre><code class=\"language-python\">def binarySearch(a, x):\n  \"Binary search to find x in list a\"\n  lower = -1\n  upper = len(a)\n  while upper > lower + 1:\n    mid = (lower + upper) // 2\n    if a[mid] == x:\n      return mid\n    if x &#x3C; a[mid]:\n      upper = mid\n    else:\n      lower = mid\n  return None\n</code></pre>\n<p><em>Binary search imlementation in Python</em></p>\n<p><ad-incontent></ad-incontent></p>\n<p>At the start of our binary search algorithm example, we are defining a function named: <code>binarySearch</code> which accept two arguments(<code>a</code> and <code>x</code>) where <code>a</code> is the list and the <code>x</code> is the item we are searching for in the list. Inside the <code>binarySearch</code> function we have two variables <code>lower</code> and <code>upper</code> which will be the initial points where we start and stop with searching in the list. At any point in the binary search algorithm, lower will be one index less\nthen the index of the first item in the region and upper will be one more than the index of the last item in the region. The first step on each round of the binary search algorithm is to compute the location in the middle of the region. If the item we are searching for (<code>x</code>) is at that location the search terminates successfully. Otherwise, we need to find the middle of the region. It’s simply the index value that is halfway between lower and upper:</p>\n<p><code>mid = (lower + upper) // 2</code></p>\n<p>If the list item at this location is equal to <code>x</code>, the value we are searching for, we return mid as the final result. If the item is not at the midpoint we have to continue the search, and we will reduce the size of the region. To do that we simply have to move one of the boundaries so it is equal to the current midpoint.</p>\n<h2>Analysis of Binary Search Algorithm</h2>\n<p>For a given list with n size of items, the best case is when the value is equal to the first item of the list <code>O(1)</code>, in which case only one comparison is needed. If we know that the item is in the list, the worst case will be the <code>O(log n)</code> eg. the first or the last item because we have to do a maximum number of comparisons. In terms of average performances, no search algorithm that works only by comparing items can have better average performance than binary search which is <code>O(log n)</code>.</p>\n<blockquote>\n<p>If you want to learn more in-depth about algorithms and data structures, I highly recommend you to check this book: <a href=\"https://www.amazon.com/gp/product/0262033844/ref=as_li_tl?ie=UTF8&camp=1789&creative=9325&creativeASIN=0262033844&linkCode=as2&tag=aleksandarvas-20&linkId=7819ac46596f8e04995f1f860dd49098\" style=\"font-weight:bold; color:#00a4ccff; text-decoration: underline;\">Introduction to Algorithms, 3rd Edition (The MIT Press)</a></p>\n</blockquote>","frontmatter":{"path":"/algorithms-and-data-structures-binary-search/","date":"2020-04-13T21:40:00.619Z","title":"Data Structures and Algorithms: Binary Search","author":"Aleksandar Vasilevski","image":"/assets/cover/puzzle.jpg","category":"DSA","tags":"#algorithms #datastructures","featured":false}}},{"node":{"id":"1c30fda2-ebb0-5b38-8f80-a8756a07d0a5","html":"<p><img src=\"/assets/cover/puzzle.jpg\" alt=\"rubik-cube\"></p>\n<h2>The Insertion Sort Algorithm</h2>\n<img style=\"float: right\" src=\"/assets/samples/insertion-sort-1.png\"/>\nInsertion sort is a simple sorting algorithm that builds the final sorted array one item at a time. This algorithm is a simple technique that is easy to understand and implement. The steps done by this algorithm are an iterative solution of how a complex problem can be solved by repeatedly executing very simple steps. To understand how the insertion sort works, imagine that you have a couple of cards in one hand and you need to put them in order of their rank. One way to do it is to make sure cards on the left side in your have been sorted. Then pick up the third card (which is first not sorted) and place it on proper order among the first two cards. At any point in this process, we have two parts, the left part which is sorted and the right part which is not sorted. After each round of insertions, the sorted part grows longer, and the algorithm stops when the last card has been placed where it belongs and the entire hand is sorted.\n<div style=\"text-align:justify;\">\n  <img src=\"/assets/samples/insertion-sort-2.gif\" style=\"margin:auto; display:block;\"/>\n  <p style=\"text-align:center;\"><em>Insertion sort algorithm visual example</em></p>\n</div>\n<h2>Implementing Insertion Sort Algorithm</h2>\n<p>Insertion sort algorithm is simple to implement, if we want to write an insertion sort algorithm we will need to use a for-loop inside the main function which we will be using it to iterate over all of the elements in the list and a while-loop inside the helper function which will be doing the most of the work. Let's see an example of an insertion sort algorithm in Python.</p>\n<pre><code class=\"language-python\">#insertion sort function\ndef insertionSort(a):\n  for i in range(1, len(a)):\n    moveLeft(a, i)\n\n#helper function that moves a[j]\ndef moveLeft(a, j):\n  x = a.pop(j)\n  while j > 0 and a[j - 1] > x:\n    j -= 1\n  a.insert(j, x)\n</code></pre>\n<p><em>Insertion sort imlementation in Python</em></p>\n<p><ad-incontent></ad-incontent></p>\n<p>At the beginning of the example, we are defining a function <code>insertionSort</code> with one argument (<code>a</code>) which is the list. Inside the function, we have a for-loop that iterates through every element from the 1 (which is the second element, because the first is already sorted) to the end at the size of the list. Inside we have a helper function called <code>moveLeft</code> where we pass the reference to the list as the first argument <code>a</code> and the current index <code>j</code>. Removing the item at a specified location is straightforward, we simply need to call a method named pop defined in the list class, and it will remove the object at location <code>j</code> and saves it in <code>x</code>. On the next line, we have a while-loop that implements our leftward scan. Because <code>j</code> is the location where <code>x</code> was used to be, the first time the program executes the while-loop it will compare <code>x</code> to the item that was to its left. If the element on the left is larger it will need to go further to the left. The line with the <code>j -= 1</code> in the while-loop subtracts one from j. On the last line, we simply insert the <code>x</code> at index <code>j</code> into the list <code>a</code>.</p>\n<h2>Analysis of Insertion Sort Algorithm</h2>\n<p>The best case input about the insertion sort algorithm is when the list is already sorted, which has a linear running time (i.e., O(n)). The worst-case input is when the list is sorted in reverse order, this gives us a quadratic running time (i.e., O(n2)). The average case is also quadratic, which puts insertion sort not very useful for sorting large lists. However, insertion sort is one of the fastest algorithms for sorting very small lists. For a given list with n size of items, the best case is when the value is equal to the first element of the list, in which case only one comparison is needed. The worst case is when the value is not in the list or occurs only once at the end of the list, in which case n comparisons are needed.</p>\n<blockquote>\n<p>If you want to learn more in-depth about algorithms and data structures, I highly recommend you to check this book: <a href=\"https://www.amazon.com/gp/product/0262033844/ref=as_li_tl?ie=UTF8&camp=1789&creative=9325&creativeASIN=0262033844&linkCode=as2&tag=aleksandarvas-20&linkId=7819ac46596f8e04995f1f860dd49098\" style=\"font-weight:bold; color:#00a4ccff; text-decoration: underline;\">Introduction to Algorithms, 3rd Edition (The MIT Press)</a></p>\n</blockquote>","frontmatter":{"path":"/algorithms-and-data-structures-insertion-sort/","date":"2020-03-06T19:20:49.619Z","title":"Data Structures and Algorithms: Insertion Sort","author":"Aleksandar Vasilevski","image":"/assets/cover/puzzle.jpg","category":"DSA","tags":"#algorithms #datastructures","featured":false}}},{"node":{"id":"61a1182f-ec59-5755-bb69-00376f77a407","html":"<p><img src=\"/assets/cover/puzzle.jpg\" alt=\"rubik-cube\"></p>\n<h2>The Linear Search Algorithm</h2>\n<p><img style=\"float: right\" src=\"/assets/samples/linear-search-1.png\"></img>\nAs the name says a linear search is a process that starts at the beginning of a list and goes through every element (one item at a time) until it finds the element which is looking for. To find the element which is searching for (for example we are searching for <code>x</code>), a linear search algorithm is comparing every element in the list with the value inside of <code>x</code>, until a match is found or the whole list has been searched. Performance for using linear search in large lists is bad because it makes at most n comparisons, where n is the length of the list. In practice, linear search algorithm is rarely being used because other search algorithms like the binary search algorithm allow significantly faster searching for all but shortlists.</p>\n<h2>Implementing Linear Search Algorithm</h2>\n<p>A linear search algorithm is usually simple to implement and is practical when the list is short with only a few elements, or when we are performing a single search in an unordered list.\nIf we want to write a linear search algorithm obvious choice will be to use a for loop. To search the list we will be using a range expression to get all index values from 0 to the length of the list minus one. We will be testing every index in the body of the loop to see if it contains the item which we are searching for. Let's see an example of a linear search algorithm in Python using a for-loop.</p>\n<pre><code class=\"language-python\">def linearSearch(a, x):\n  for i in range (0, len(a)):\n    if a[i] == x:\n      return i\n  return None\n</code></pre>\n<p><em>Linear search imlementation in Python using for loop</em></p>\n<p><ad-incontent></ad-incontent></p>\n<p>At the beginning of the example we are defining a function <code>linearSearch</code> with two arguments (<code>a</code> and <code>x</code>) where <code>a</code> is the list and the <code>x</code> is the element we are searching for. Inside the function, we have for-loop which iterate through every item from the start at 0 to the end at the size of the list. Inside the for-loop we are testing every index(<code>a[i]</code>) with the value of <code>x</code>, if the test is true we are returning the index where we wound the element. If the for-loop ends and no matching element is found in the list, the function will return <code>None</code> at the end.</p>\n<p>We can also use a while-loop instead of for-loop for the linear search algorithm, using the for-loop the code look cleaner but at the end is the matter of writing style.</p>\n<h2>Analysis of Linear Search Algorithm</h2>\n<p>For a given list with n size of items, the best case is when the value is equal to the first element of the list, in which case only one comparison is needed. The worst case is when the value is not in the list or occurs only once at the end of the list, in which case n comparisons are needed.</p>\n<blockquote>\n<p>If you want to learn more in-depth about algorithms and data structures, I highly recommend you to check this book: <a href=\"https://www.amazon.com/gp/product/0262033844/ref=as_li_tl?ie=UTF8&camp=1789&creative=9325&creativeASIN=0262033844&linkCode=as2&tag=aleksandarvas-20&linkId=7819ac46596f8e04995f1f860dd49098\" style=\"font-weight:bold; color:#00a4ccff; text-decoration: underline;\">Introduction to Algorithms, 3rd Edition (The MIT Press)</a></p>\n</blockquote>","frontmatter":{"path":"/algorithms-and-data-structures-linear-search/","date":"2020-03-03T13:20:49.619Z","title":"Data Structures and Algorithms: Linear Search","author":"Aleksandar Vasilevski","image":"/assets/cover/puzzle.jpg","category":"DSA","tags":"#algorithms #datastructures","featured":false}}},{"node":{"id":"e3e070c2-9615-5432-abb3-4d017d8948a8","html":"<p><img src=\"/assets/cover/javascript.png\" alt=\"js-logo\"></p>\n<p>JavaScript is a widely-used programming language today in web development, in both front-end and back-end development, and proper email validation is a must-know skill for every software developer. </p>\n<p>When we are developing any website or application in JavaScript, we must create some kind of form from where we are getting the emails from the users. It is very important to validate the input field, before doing something else with that piece of information.</p>\n<p><ad-incontent></ad-incontent></p>\n<h2>Methods to validate Email in JavaScript</h2>\n<p>There are many ways to validate email address, the three most popular ways are:</p>\n<ul>\n<li>Using the regex expression</li>\n<li>Using HTML in-built email validation</li>\n<li>Using a third party library</li>\n</ul>\n<p>As using regex expression is most popular, we will take a look at how we can validate an email address with a regex expression.</p>\n<h2>Before We Start Email Validating</h2>\n<p>Before we start writing the regex expression, we need to know the basics of email validation.</p>\n<p>Most of the email addresses are with two parts, the local part and domain part.</p>\n<p>The local part of the email address can contain the following:</p>\n<ul>\n<li>Any letter or number: a-z, A-Z, 0-9.</li>\n<li>A dot (.) but should not be first or last character.</li>\n<li>punctuation: “(),:;&#x3C;>@[]</li>\n<li>special characters: !#$%&#x26;’*+-/=?^_{|}~</li>\n</ul>\n<p>The domain part of the email address can contain the following:</p>\n<ul>\n<li>Any letter or number: a-z, A-Z, 0-9.</li>\n<li>The hyphen (-) but should not be first or last character.</li>\n</ul>\n<p><ad-incontent></ad-incontent></p>\n<h2>Email validation using the Regex Expression</h2>\n<p>There is no general expression to validate an email address. Every developer out there is using a different set of regex in their program to validate an email address. Before we use any regex in our code, we first need to validate it with testing some email addresses, both valid and invalid.</p>\n<pre><code class=\"language-javascript\">/^(([^&#x3C;>()\\[\\]\\\\.,;:\\s@\"]+(\\.[^&#x3C;>()\\[\\]\\\\.,;:\\s@\"]+)*)|(\".+\"))@((\\[[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\])|(([a-zA-Z\\-0-9]+\\.)+[a-zA-Z]{2,}))$/\n</code></pre>\n<p>The above example is a regex that can validate almost all (99%) of the email addresses.</p>\n<h2>Regex Example using JavaScript to Validate Email Adresses</h2>\n<pre><code class=\"language-javascript\">const validateEmail = (email)  => {\n    const re = /^(([^&#x3C;>()\\[\\]\\\\.,;:\\s@\"]+(\\.[^&#x3C;>()\\[\\]\\\\.,;:\\s@\"]+)*)|(\".+\"))@((\\[[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\])|(([a-zA-Z\\-0-9]+\\.)+[a-zA-Z]{2,}))$/;\n    return re.test(email.toLowerCase());\n}\n</code></pre>\n<p>In the example above we have a simple JavaScript arrow function, which will validate any email address we insert. The code above is not hard to understand, we are simply using a regular expression to compare it with the email address provided after it is converted to lowercase.</p>\n<h2>Conclusion</h2>\n<p>We have converted the most important parts about email validation in JavaScript using the regex expression, As you can see it is not hard at all, although the regex which we use is not easy to understand.</p>","frontmatter":{"path":"/javascript-email-validation/","date":"2020-02-13T19:30:49.619Z","title":"How to Validate Email Address in JavaScript","author":"Aleksandar Vasilevski","image":"/assets/cover/javascript.png","category":"JavaScript","tags":"#javascript #validation","featured":false}}},{"node":{"id":"6f250f20-808c-533b-8649-2f4034378c5f","html":"<p><img src=\"/assets/cover/javascript.png\" alt=\"javascript-logo\"></p>\n<p>To be able to see the bigger picture of some piece of code you must know how that particular programming language works under the hood. In this article, we will see how the JavaScript works behind the scenes.</p>\n<h2>Execution Context and Window Object</h2>\n<p>Every block of code written to work properly it needs some environment when it can run, and it is no different for the JavaScript too. Say hi to the <strong>Execution Context</strong> which is the place where the JavaScript code is running. To have a picture of the Execution Context, think of it like some kind of box, container or wrapper which stores variables and which a piece of JavaScript code is evaluated and executed.</p>\n<p><ad-incontent></ad-incontent></p>\n<h3>Global Execution Context</h3>\n<p>The default execution context is the <strong>global execution context</strong>, which means all of the code (variables and functions) that is not inside of any function is executed. You can think of this Global Execution Context as some global object which is the <strong>window</strong> object. Everything that we declare in the global context is attached to the window object, for example:</p>\n<pre><code class=\"language-javascript\">var firstName = \"Ace\";\nfirstName === window.firstName // True\n</code></pre>\n<p>Declaring the variable <code>firstName</code> or <code>window.firstName</code> is the same thing, think of it like <code>firstName</code> is a property of window object.</p>\n<h3>Function Execution Context</h3>\n<p>What about the code that is in functions? each time we call a function, that function is getting a new execution context called <strong>function execution context</strong> on the top of the <strong>execution stack</strong>. Let's see some practical example:</p>\n<pre><code class=\"language-javascript\">var name = \"Ace\";\n\nfunction first(){\n  var a = \"Hello\";\n  second();\n  var x = a + name;\n}\n\nfunction second(){\n  var b = \"Hi\";\n  third();\n  var z = b + name;\n}\n\nfunction third(){\n  var c = \"Hola\";\n  var z = c + name;\n}\n\nfirst();\n</code></pre>\n<p>Our first declaration, the variable <code>name</code> is not in any function, which means we are in the global execution context. The <code>function first()</code>, <code>function second()</code> and <code>function third()</code> declarations are also in the same execution context. When we go to the last line (49) where the <code>first()</code> function is called, we will get a new execution context on the top of the execution stack. Every execution context that is on the top of the execution stack becomes an active context in which the code is executed. </p>\n<p><ad-incontent></ad-incontent></p>\n<p>Now inside our new execution context (line 33), we have a variable <code>a</code> stored, on the next line (34) we call the second function which again new execution context will be created on top of the execution stack, which also now becomes an active context. </p>\n<p>Here inside the execution context of the second function, we have a variable <code>b</code> stored inline 39. Inline 40 we are calling the third function which will again create a new execution context on top of the execution stack.</p>\n<p>Inside the execution context of the third function, we have a variable <code>c</code> and <code>z</code> and nothing more. So our third function has finished all of its work and we say that the function returns, and it's execution context it's removed from the top of the execution stack.</p>\n<p><img src=\"/assets/samples/execution-stack.png\" alt=\"execution-stack\"></p>\n<p>After that, the context of the second function which called the third function becomes the active context again, and we continue on line 41. Now the <code>z</code> variable is updated and the second function finishes all of its work and returns, which it's execution context is also removed from the stack.</p>\n<p>Now the context of the first function is again the active context, and the code continues on line 35 where the <code>x</code> variable is updated and because there is no more work to be done inside the first function, we say again that the function returns and its execution context is removed from the execution stack.</p>\n<h2>How Execution Context is Created</h2>\n<p>As we said before we can associate an execution context with an object, this object has three properties: </p>\n<ol>\n<li><strong>Variable Object (VO)</strong> - which contains function arguments, inner variable declarations and functions declarations.</li>\n<li><strong>Scope Chain</strong> - which contains the current variable objects as well as the variable objects of all of its parents.</li>\n<li><strong>\"This\" variable</strong> - which is pointing to the current object.  </li>\n</ol>\n<p><ad-incontent></ad-incontent></p>\n<p>Now let's see how the execution context is created. As we said before when a function is started an execution context is put on top of the execution stack, this process happens in two phases:</p>\n<ol>\n<li><strong>Creation phase</strong></li>\n<li><strong>Execution phase</strong></li>\n</ol>\n<p>In the creation phase we first have the creation of the Variable Object, second the creation of the Scope Chain, and at the end \"this\" variable is set.\nIn the execution phase, the code that generated the current execution context is run line by line, and all of the variables are defined. If it is the global context, then it is the global code that is executed.</p>\n<blockquote>\n<p>If you want to go deeper about how JavaScript works, I can recommend you to read this book: <a href=\"https://www.amazon.com/gp/product/1949815005/ref=as_li_tl?ie=UTF8&#x26;camp=1789&#x26;creative=9325&#x26;creativeASIN=1949815005&#x26;linkCode=as2&#x26;tag=aleksandarvas-20&#x26;linkId=fe67c83d8fa8335abe77873dd6c7944a\"><strong>How JavaScript Works</strong></a>.</p>\n</blockquote>","frontmatter":{"path":"/how-javascript-works-execution-context/","date":"2020-01-29T16:30:49.619Z","title":"How JavaScript Works: Execution Context","author":"Aleksandar Vasilevski","image":"/assets/cover/javascript.png","category":"JavaScript","tags":"#javascript","featured":false}}},{"node":{"id":"77f56526-c8e2-50ad-9b9a-26dd1fdef53d","html":"<p><img src=\"/assets/cover/javascript.png\" alt=\"javascript-logo\"></p>\n<p>Creating elements using HTML is not the only way to do it, although most of the time we are creating elements directly in the Html document because of simplicity, it is possible to be also done with JavaScript. In this article, we will take a look at how we can create elements with JavaScript only, and we will see how the JavaScript is doing that under the hood.</p>\n<blockquote>\n<p>The <strong>Document Object Model (DOM)</strong> is a platform and language-neutral interface that allows programs and scripts to dynamically access and update the content, structure, and style of a document.</p>\n</blockquote>\n<p><ad-incontent></ad-incontent></p>\n<h2>JavaScript Create Element</h2>\n<p>Creating DOM elements using js, adding text to the new element and appending the child to the Html body is not a hard task, it can be done in just a couple of lines of code. Let's see in the next example:</p>\n<pre><code class=\"language-javascript\">var div = document.createElement('div');  //creating element\ndiv.textContent = \"Hello, World\";         //adding text on the element\ndocument.body.appendChild(div);           //appending the element\n</code></pre>\n<p>In the example above, on the first line, we are creating new div with the method <code>createElement()</code> which has been called on the document object. In the method, we are passing an argument telling which element we want to be created. On the second line, we are using the <code>textContent</code> property to add text to our newly created element. Lastly, on the third line, we are using the document, body property to call the <code>appendChild()</code> method and pass our element we want to append to the body, in our case the newly created div element.</p>\n<p>So as we can see, the code above is equivalent to:</p>\n<pre><code class=\"language-html\">&#x3C;body>\n  &#x3C;div>Hello, World&#x3C;/div>\n&#x3C;/body>\n</code></pre>\n<h2>JavaScript Remove Element</h2>\n<p>Removing DOM elements is also simple and easy as creating DOM elements. Each DOM element has a property that’s the DOM element’s parent. To remove an element, we just need to call the <code>removeChild()</code> method, and pass the child element we want to remove as an argument to the same method:</p>\n<pre><code class=\"language-javascript\">div.parentNode.removeChild(div);\n</code></pre>\n<p>As you can see it is even simpler than creating elements!.</p>\n<p><ad-incontent></ad-incontent></p>\n<h2>Create Element with jQuery</h2>\n<p>As an alternative to vanilla JavaScript, we can use the jQuery library to do the same things as creating, adding, removing DOM elements, etc.</p>\n<pre><code class=\"language-javascript\">var div = $('&#x3C;div/>').text(\"Hello, World\").appendTo(document.body);\n</code></pre>\n<blockquote>\n<p>In the long run, using jQuery can be not the best thing because, with today's demand for modern technologies like React, vanilla JavaScript is a much better skillset.</p>\n</blockquote>\n<p>Now I hope you can understand how does the creating, adding and removing of DOM elements works in JavaScript and jQuery. If you find this article helpful feel free to share it.</p>","frontmatter":{"path":"/javascript-create-element/","date":"2020-01-22T10:40:49.619Z","title":"How to Create HTML Element in JavaScript","author":"Aleksandar Vasilevski","image":"/assets/cover/javascript.png","category":"JavaScript","tags":"#javascript","featured":false}}},{"node":{"id":"07d439b6-9f68-5582-9257-12c25e22485d","html":"<p><img src=\"/assets/css.jpg\" alt=\"css-logo\"></p>\n<p>Adding CSS hover effects to a web site is a great way to draw the attention of the users and make the website to be more engaging. In this article, you will learn how to do 10 simple CSS hover effects for your web site or blog.</p>\n<p>Before we start, we will set up a button with some Html and Css with very simple rules on it.</p>\n<blockquote>\n<p>For this article we will use the core CSS styles for all of the transitions and animations.</p>\n</blockquote>\n<pre><code class=\"language-html\">&#x3C;button>Hover Effects&#x3C;/button>\n</code></pre>\n<pre><code class=\"language-css\">button {\n  border: none;\n  background: #ff7a59;\n  color: #fff;\n  padding: 10px;\n  font-size: 16px;\n  border-radius: 5px;\n  position: relative;\n  box-sizing: border-box;\n  transition: all 500ms ease; \n}\n</code></pre>\n<p>Now let's see some easy CSS3 hover effects.</p>\n<p><ad-incontent></ad-incontent></p>\n<h2>Ghost Button</h2>\n<p>We will start with the simplest hover effects of all, ghost button which change the color of the button on hover. This CSS hover effect is simple but very effective, great for almost every action button. To do it we just add a <code>:hover</code> on it with different values from the original:</p>\n<pre><code class=\"language-css\">button:hover{\n  color: #ff7a59;\n  border: #ff7a59 solid 1px;\n  background:#fff;\n}\n</code></pre>\n<h2>Animate Icon In</h2>\n<p>This effect is great to be used for functions, for example when doing some actions like submitting some form. This effect is a sliding icon that will appear next to the text when you hover over the button. Firstly we will add more padding because we need more room for the icon, also we will set the overflow to hidden:</p>\n<pre><code class=\"language-css\">button{ \n  padding: 10px 40px;  \n  overflow:hidden;\n}\n</code></pre>\n<p>The next step is to add some icon (you can use Font Awesome) and in the <code>::before</code> pseudo-element and set the position outside the button.</p>\n<pre><code class=\"language-css\">button:before {\n  font-family: FontAwesome;\n  content:\"\\f07a\";\n  position: absolute;\n  top: 11px;\n  left: -30px;\n  transition: all 300ms ease;\n}\n</code></pre>\n<p>The last thing which we need to do is to animate in the icon with setting the <em>left</em> property:</p>\n<pre><code class=\"language-css\">button:hover:before {\n  left: 7px;\n}\n</code></pre>\n<p><ad-incontent></ad-incontent></p>\n<h2>Fade In</h2>\n<p>Fade In effect is fairly commonly used because it is a great CSS effect to draw user attention to a call to action. Fade-in effects are in two steps, the initial phase, and the hover phase:</p>\n<pre><code class=\"language-css\">button{\n  opacity:0.5;\n}\nbutton:hover{\n  opacity:1;\n}\n</code></pre>\n<h2>Grow In</h2>\n<p>Like the previous effect, this one is also great for getting the user's attention for a call to action because the button will grow when it hovers.</p>\n<pre><code class=\"language-css\">button:hover{\n  -webkit-transform: scale(1.2);\n  -ms-transform: scale(1.2);\n  transform: scale(1.2);\n}\n</code></pre>\n<h2>Bounce</h2>\n<p>For this animated CSS effect, we are going to use some keyframes for the button to enable a bounce effect when it hovers. This effect is always effective for grabbing the user's attention.</p>\n<pre><code class=\"language-css\">@keyframes bounce {\n  0%, 20%, 60%, 100% {\n    -webkit-transform: translateY(0);\n    transform: translateY(0);\n  }\n\n  40% {\n    -webkit-transform: translateY(-20px);\n    transform: translateY(-20px);\n  }\n\n  80% {\n    -webkit-transform: translateY(-10px);\n    transform: translateY(-10px);\n  }\n}\n</code></pre>\n<p>And lastly, we just need to apply the animation on hover:</p>\n<pre><code class=\"language-css\">button:hover {\n  animation: bounce 1s;\n}\n</code></pre>\n<h2>Skew</h2>\n<p>Another great transition in CSS3 is the skew. Using this transition effects is incredibly simple, we just need to set it on hover:</p>\n<pre><code class=\"language-css\">button:hover {\n  transform: skew(-10deg);\n}\n</code></pre>\n<h2>Highlight Border</h2>\n<p>This hover effect is very much similar to the ghost button, here instead of the regular border we will be doing a dotted border:</p>\n<pre><code class=\"language-css\">button {\n  border: 3px solid #ff7a59;\n}\n\nbutton:hover {\n  border: 3px dotted #ff7a59;\n  color: #ff7a59;\n  background: #fff;\n}\n</code></pre>\n<p><ad-incontent></ad-incontent></p>\n<h2>Flip 3D</h2>\n<p>Our last effect will make the button flipping over to show a message, which will be added in the after pseudo-element of the button. To do that, firstly we will set the button’s transform style to preserve-3d so that children of the element will preserve their 3D position:</p>\n<pre><code class=\"language-css\">button {\n  transform-style: preserve-3d;\n}\n</code></pre>\n<p>Next, we will set up the pseudo-element:</p>\n<pre><code class=\"language-css\">button:after {\n  top: -100%;\n  left: 0px;\n  width: 100%;\n  position: absolute;\n  background: #ff7a59;\n  border-radius: 5px;\n  content: 'Flipped';\n  transform-origin: left bottom;\n  transform: rotateX(90deg);\n}\n</code></pre>\n<p>And in the end, we just need to create the hover animation:</p>\n<pre><code class=\"language-css\">button:hover {\n  transform-origin: center bottom;\n  transform: rotateX(-90deg) translateY(100%);\n}\n</code></pre>\n<p>As you can see every CSS transition effect we have seen takes just a couple of minutes to be set up in any project, some of them can be done even in secondes!. I find the article helpful please share it.</p>","frontmatter":{"path":"/css-hover-effects/","date":"2020-01-21T13:00:00.619Z","title":"8 Easy CSS Hover Effects","author":"Aleksandar Vasilevski","image":"/assets/css.jpg","category":"CSS","tags":"#css #html #hover #effects","featured":false}}},{"node":{"id":"acbe61d2-e8cb-5f61-a7e1-ff66d49eeb15","html":"<p><img src=\"/assets/cover/you-dont-know-js.jpg\" alt=\"you-dont-know-js-cover\"></p>\n<p>There are many books about the JavaScript programming language out there, some of them are worth reading, some are not. In this article, we will take a close look at the You Don't Know JS.</p>\n<p>You Don't Know JS is not just one book but there are six of them. They are ordered below from the first to the last.</p>\n<p><ad-incontent></ad-incontent></p>\n<p>Even if your experience and knowledge in JavaScript are great and you think that you know everything about the language, every time you read these books again you will understand something much better or if you are reading them for the first time you will learn something new about the JavaScript programming language for sure. </p>\n<h2>You Don't Know JS: Up &#x26; Going</h2>\n<p>The first book <strong>\"Up &#x26; Going\"</strong> is mostly focusing on the basic building blocks of programming, and it is great for absolute beginners in programming. Up &#x26; Going will introduce you to things like operators, types, variables, conditionals, loops, functions, etc. </p>\n<div style=\"display:flex;justify-content:space-evenly;flex-wrap:wrap;\">\n    <iframe style=\"width:120px;height:240px;\" marginwidth=\"0\" marginheight=\"0\" scrolling=\"no\" frameborder=\"0\" src=\"//ws-na.amazon-adsystem.com/widgets/q?ServiceVersion=20070822&OneJS=1&Operation=GetAdHtml&MarketPlace=US&source=ac&ref=tf_til&ad_type=product_link&tracking_id=aleksandarvas-20&marketplace=amazon&region=US&placement=1491924462&asins=1491924462&linkId=43d3241ab533467ed4888b6f99496c1d&show_border=false&link_opens_in_new_window=false&price_color=333333&title_color=0066c0&bg_color=ffffff\">\n        </iframe>\n  </div>\n<h2>You Don't Know JS: Scope and Closures</h2>\n<p>The second book <strong>\"Scope and Closures\"</strong> as the name it is focused on in-depth inside scope and closures, which are the two core concepts you need to know to become a better JavaScript programmer. You will see how they work and why they are the trickier parts of the language that many JavaScript programmers are trying to avoid.</p>\n<div style=\"display:flex;justify-content:space-evenly;flex-wrap:wrap;\">\n  <iframe style=\"width:120px;height:240px;\" marginwidth=\"0\" marginheight=\"0\" scrolling=\"no\" frameborder=\"0\" src=\"//ws-na.amazon-adsystem.com/widgets/q?ServiceVersion=20070822&OneJS=1&Operation=GetAdHtml&MarketPlace=US&source=ac&ref=tf_til&ad_type=product_link&tracking_id=aleksandarvas-20&marketplace=amazon&region=US&placement=1449335586&asins=1449335586&linkId=32b47c91aadebf2f59b2c251047f9050&show_border=false&link_opens_in_new_window=false&price_color=333333&title_color=0066c0&bg_color=ffffff\">\n      </iframe>\n  </div>\n<h2>You Don't Know JS: this &#x26; Object Prototypes</h2>\n<p>Third book of the You Don't Know JS series: <strong>this &#x26; Object Prototypes</strong> will take you to the JavaScript object-oriented programming, and why you need to use it. You will look into the nature of JavaScript objects, prototypes, classes, inheritance, etc.</p>\n<div style=\"display:flex;justify-content:space-evenly;flex-wrap:wrap;\">\n  <iframe style=\"width:120px;height:240px;\" marginwidth=\"0\" marginheight=\"0\" scrolling=\"no\" frameborder=\"0\" src=\"//ws-na.amazon-adsystem.com/widgets/q?ServiceVersion=20070822&OneJS=1&Operation=GetAdHtml&MarketPlace=US&source=ac&ref=tf_til&ad_type=product_link&tracking_id=aleksandarvas-20&marketplace=amazon&region=US&placement=1491904151&asins=1491904151&linkId=52aeed504c126d46c610c7a2647c84b3&show_border=false&link_opens_in_new_window=false&price_color=333333&title_color=0066c0&bg_color=ffffff\">\n      </iframe>\n  </div>\n<h2>You Don't Know JS: Types &#x26; Grammar</h2>\n<p>The fourth book of the series the <strong>Types &#x26; Grammar</strong> like the other books dives into trickier parts of the language. Many JS developers believe that JavaScript has no types. Is that true? read this book and find out.</p>\n<div style=\"display:flex;justify-content:space-evenly;flex-wrap:wrap;\">\n  <iframe style=\"width:120px;height:240px;\" marginwidth=\"0\" marginheight=\"0\" scrolling=\"no\" frameborder=\"0\" src=\"//ws-na.amazon-adsystem.com/widgets/q?ServiceVersion=20070822&OneJS=1&Operation=GetAdHtml&MarketPlace=US&source=ac&ref=tf_til&ad_type=product_link&tracking_id=aleksandarvas-20&marketplace=amazon&region=US&placement=1491904194&asins=1491904194&linkId=ce4d19e671aa1a758c9f0e4a6c1dc3e2&show_border=false&link_opens_in_new_window=false&price_color=333333&title_color=0066c0&bg_color=ffffff\">\n      </iframe>\n  </div>\n<h2>You Don't Know JS: Async &#x26; Performance</h2>\n<p>The fifth book <strong>Async &#x26; Performance</strong> focuses on asynchronous features and performance tweaks which include the usage of Promises, generators, and Web Workers, which let you create modern single-page web applications. This book is my personal favorite.</p>\n<div style=\"display:flex;justify-content:space-evenly;flex-wrap:wrap;\">\n  <iframe style=\"width:120px;height:240px;\" marginwidth=\"0\" marginheight=\"0\" scrolling=\"no\" frameborder=\"0\" src=\"//ws-na.amazon-adsystem.com/widgets/q?ServiceVersion=20070822&OneJS=1&Operation=GetAdHtml&MarketPlace=US&source=ac&ref=tf_til&ad_type=product_link&tracking_id=aleksandarvas-20&marketplace=amazon&region=US&placement=1491904224&asins=1491904224&linkId=e34f024b79964469229f2ab36f082e72&show_border=false&link_opens_in_new_window=false&price_color=333333&title_color=0066c0&bg_color=ffffff\">\n      </iframe>\n  </div>\n<h2>You Don't Know JS: ES6 &#x26; Beyond</h2>\n<p>The last book of the You Don't Know JS called <strong>ES6 &#x26; Beyond</strong> focuses on the modern part of the language. Here you will learn the ES6 syntax that will make your life much easier. You will take a look at how to organize your code with iterators, generators, modules, and classes.</p>\n<div style=\"display:flex;justify-content:space-evenly;flex-wrap:wrap;\">\n  <iframe style=\"width:120px;height:240px;\" marginwidth=\"0\" marginheight=\"0\" scrolling=\"no\" frameborder=\"0\" src=\"//ws-na.amazon-adsystem.com/widgets/q?ServiceVersion=20070822&OneJS=1&Operation=GetAdHtml&MarketPlace=US&source=ac&ref=tf_til&ad_type=product_link&tracking_id=aleksandarvas-20&marketplace=amazon&region=US&placement=1491904240&asins=1491904240&linkId=84a71c790e46a218deacc59561685dfe&show_border=false&link_opens_in_new_window=false&price_color=333333&title_color=0066c0&bg_color=ffffff\">\n      </iframe>\n  </div>\n<p>Are You Don't Know JS the best JavaScript books? probably, especially if you are a big fan of the JS, if you are an absolute beginner and you want to dive into web development they are also a great way to learn JavaScript, if you are experienced programmer you will still learn a lot from them and in the end, these books are worth having them in your collection.</p>\n<p>You can check You Don't Know JS books on the links below:</p>\n<p><a href=\"https://www.amazon.com/gp/product/1491924462/ref=as_li_tl?ie=UTF8&camp=1789&creative=9325&creativeASIN=1491924462&linkCode=as2&tag=aleksandarvas-20&linkId=6e0a99c1b807402b79587ae7cb2a0a8e\" style=\"font-weight:bold; text-decoration:underline; color:#ff7a59;\">You Don't Know Js: Up &#x26; Going</a></p>\n<p><a href=\"https://www.amazon.com/gp/product/1449335586/ref=as_li_tl?ie=UTF8&camp=1789&creative=9325&creativeASIN=1449335586&linkCode=as2&tag=aleksandarvas-20&linkId=63c3d4f7c6db713ec923b7d4590fcdc0\" style=\"font-weight:bold; text-decoration:underline; color:#ff7a59;\">You Don't Know JS: Scope &#x26; Closures</a></p>\n<p><a href=\"https://www.amazon.com/gp/product/1491904151/ref=as_li_tl?ie=UTF8&camp=1789&creative=9325&creativeASIN=1491904151&linkCode=as2&tag=aleksandarvas-20&linkId=f2d2db01ca6738f099cae0bccea0ecc2\" style=\"font-weight:bold; text-decoration:underline; color:#ff7a59;\">You Don't Know Js: this &#x26; Object Prototypes</a></p>\n<p><a href=\"https://www.amazon.com/gp/product/1491904194/ref=as_li_tl?ie=UTF8&camp=1789&creative=9325&creativeASIN=1491904194&linkCode=as2&tag=aleksandarvas-20&linkId=eeeb2ca348428616ae5bd5683bd809ee\" style=\"font-weight:bold; text-decoration:underline; color:#ff7a59;\">You Don't Know Js: Types &#x26; Grammar</a></p>\n<p><a href=\"https://www.amazon.com/gp/product/1491904224/ref=as_li_tl?ie=UTF8&camp=1789&creative=9325&creativeASIN=1491904224&linkCode=as2&tag=aleksandarvas-20&linkId=1c3608eee769d2838e5417beff71f1b1\" style=\"font-weight:bold; text-decoration:underline; color:#ff7a59;\">You Don't Know Js: Async &#x26; Performance</a></p>\n<p><a href=\"https://www.amazon.com/gp/product/1491904240/ref=as_li_tl?ie=UTF8&camp=1789&creative=9325&creativeASIN=1491904240&linkCode=as2&tag=aleksandarvas-20&linkId=063996cae1419bd933d533bc2b091ddf\" style=\"font-weight:bold; text-decoration:underline; color:#ff7a59;\">You Don't Know JS: ES6 &#x26; Beyond</a></p>","frontmatter":{"path":"/review-you-dont-know-js/","date":"2020-01-18T10:15:49.619Z","title":"You Don't Know JS - Best JavaScript Books?","author":"Aleksandar Vasilevski","image":"/assets/cover/you-dont-know-js.jpg","category":"Books","tags":"#javascript #book #review","featured":false}}},{"node":{"id":"207c63f5-dc83-5a20-8c92-91e2dc74ead5","html":"<p><img src=\"/assets/cover/javascript.png\" alt=\"javascript-logo\"></p>\n<p>Arrays in JavaScript are list-like objects whose prototypes have methods to perform some operations on them. In this article, we will see the most important array methods in JavaScript, and how we can use them.</p>\n<p><ad-incontent></ad-incontent></p>\n<h2>find()</h2>\n<p>The <code>find()</code> method returns the first found element in the array, tested with the provided function. If the element is found it returns undefined.</p>\n<pre><code class=\"language-javascript\">const someArray = [\n  { id: 1, name: \"John\" },\n  { id: 2, name: \"Smith\" },\n  { id: 3, name: \"Bob\" },\n]\n\nsomeArray.find(element => element.id === 2)\n//-------> Output : {id: 2, name: \"Smith\"}\n</code></pre>\n<h2>findIndex()</h2>\n<p>The <code>findIndex()</code> method returns the index of the first found element in the array, tested with the provided function. If the index is not found it returns -1.</p>\n<pre><code class=\"language-javascript\">const someArray = [\n  { id: 1, name: \"John\" },\n  { id: 2, name: \"Smith\" },\n  { id: 3, name: \"Bob\" },\n]\n\nsomeArray.find(element => element.id === 2)\n//-------> Output : 2\n</code></pre>\n<h2>forEach()</h2>\n<p>The <code>forEach()</code> method uses a function on each element in the array.</p>\n<pre><code class=\"language-javascript\">const someArray = [\n  { id: 1, name: \"John\" },\n  { id: 2, name: \"Smith\" },\n  { id: 3, name: \"Bob\" },\n]\n\nmyAwesomeArray.forEach(element => console.log(element.name))\n//Output : John, Smith, Bob\n</code></pre>\n<p><ad-incontent></ad-incontent></p>\n<h2>map()</h2>\n<p>The <code>map()</code> method applies a function as a parameter and creates a new array populated with the results of the function on every element.</p>\n<pre><code class=\"language-javascript\">const someArray = [1, 2, 3, 4]\nsomeArray.map(x => x * x)\n\n// Output: 1, 4, 9, 16\n</code></pre>\n<blockquote>\n<p>If you are interested to read more in-depth about the <code>forEach()</code> and <code>map()</code> methods, you can check the <a href=\"https://www.codespot.org/javascript-map-vs-foreach/\"><strong>JavaScript Map vs ForEach Method</strong></a>.</p>\n</blockquote>\n<h2>flat()</h2>\n<p>The <code>flat()</code> method creates a new array as a result that contains the element from the sub-array and flat them into the new array. Remember that this method will work only one level in depth.</p>\n<pre><code class=\"language-javascript\">const someArray = [1, [2, 3], [4, 5]]\nsomeArray.flat()\n\n//Output: [1, 2, 3, 4, 5]\n</code></pre>\n<h2>flatMap()</h2>\n<p>The <code>flatMap()</code> method is a combination of the flat and map methods. This method uses a function on each element, which first maps each element using the map then flattens the result into a new array. This method only works on one level in depth.</p>\n<pre><code class=\"language-javascript\">const someArray = [[1], [2], [3], [4], [5]]\n\nsomeArray.flatMap(a => a * 10)\n\n//Output: [10, 20, 30, 40, 50]\n</code></pre>\n<p><ad-incontent></ad-incontent></p>\n<h2>filter()</h2>\n<p>The <code>filter()</code> method applies a function, which returns a new array with all elements that are passing the test.</p>\n<pre><code class=\"language-javascript\">const someArray = [\n  { id: 1, name: \"John\" },\n  { id: 2, name: \"Smith\" },\n  { id: 3, name: \"Bob\" },\n]\n\nsomeArray.filter(element => element.name === \"Bob\")\n//Output: 0:{id: 3, name: \"Bob\"}\n</code></pre>\n<h2>sort()</h2>\n<p>The <code>sort()</code> method sorts every element of the array and returns the sorted array. The sorting order by default is ascending.</p>\n<pre><code class=\"language-javascript\">const someArray = [4, 1, 3, 2]\n\n// Sort from smallest to largest\nsomeArray.sort((a, b) => a - b)\n//Output : [1, 2, 3, 4]\n\n// Sort from largest to smallest\nmyAwesomeArray.sort((a, b) => b - a)\n//Output : [4, 3, 2, 1]\n</code></pre>\n<blockquote>\n<p>The sort method is converting the elements into strings before comparing them if you want to read more about the sort method you can check the <a href=\"https://www.codespot.org/javascript-array-sort/\"><strong>JavaScript Map vs ForEach Method</strong></a>.</p>\n</blockquote>\n<h2>push()</h2>\n<p>The <code>push()</code> method adds an element to the end of the array and returns the length of the array.</p>\n<pre><code class=\"language-javascript\">const someArray = [\"Tesla\", \"Audi\", \"BMW\"]\n\nconsole.log(someArray.push(\"Toyota\"));\n//output: \"4\"\n\nconsole.log(someArray);\n//output: Array [\"Tesla\", Audi\", \"BMW\", \"Toyota\"]\n</code></pre>\n<p><ad-incontent></ad-incontent></p>\n<h2>unshift()</h2>\n<p>The <code>unshift()</code> method adds an element to the start of the array and also returns the new length of the array.</p>\n<pre><code class=\"language-javascript\">const someArray = [\"Tesla\", \"Audi\", \"BMW\"]\n\nconsole.log(someArray.unshift(\"Toyota\"));\n//output: \"4\"\n\nconsole.log(someArray);\n//output: Array [\"Toyota\", \"Tesla\", Audi\", \"BMW\"]\n</code></pre>\n<h2>shift()</h2>\n<p>The <code>shift()</code> method removes the first element from the array and returns the element. Remember that using the shift method will change the length of the array.</p>\n<pre><code class=\"language-javascript\">const someArray = [\"Tesla\", \"Audi\", \"BMW\"]\n\nconsole.log(someArray.shift());\n//output: \"Tesla\"\n\nconsole.log(someArray);\n//output: Array [\"Audi\", \"BMW\"]\n</code></pre>\n<h2>pop()</h2>\n<p>The <code>pop()</code> method removes the last element from the given array and returns the element. Remember that using the pop method will also change the length of the given array.</p>\n<pre><code class=\"language-javascript\">const someArray = [\"Tesla\", \"Audi\", \"BMW\"]\n\nconsole.log(someArray.pop());\n//output: \"BMW\"\n\nconsole.log(someArray);\n//output: Array [\"Tesla\", \"Audi\"]\n</code></pre>\n<p><ad-incontent></ad-incontent></p>\n<p>These methods are just a few of the array methods available, there are more of them for example concat, every, length, slice, etc. If you want to check them all you can check the <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array\"><em>JavaScript documentation</em></a></p>","frontmatter":{"path":"/javascript-most-important-array-methods/","date":"2020-01-15T19:55:49.619Z","title":"Most Important Array Methods in JavaScript","author":"Aleksandar Vasilevski","image":"/assets/cover/javascript.png","category":"JavaScript","tags":"#javascript","featured":false}}},{"node":{"id":"c74661e5-f0c5-5152-a8ef-d9666cff338a","html":"<p><img src=\"/assets/css.jpg\" alt=\"css-logo\"></p>\n<p>One of the best parts about the CSS3 is the animations and transitions, they are something we didn't have in the past, which it was required usage of JavaScript. Because they are so important in modern web development, there are great CSS libraries out there, one of them is the Animate.css library. In this article, we will take a close look at how to do CSS animations with Animate.css.</p>\n<h2>How to use Animate.css</h2>\n<p>As we have mentioned in the article intro, Animate.css is a CSS library that comes with cross-browser built-in animations that you can implement in your projects very fast and with ease. To start using the Animate.css library, the first thing is to download it from the GitHub page, and load the file in your HTML document:</p>\n<pre><code class=\"language-html\">&#x3C;link rel=\"stylesheet\" href=\"css/animate.min.css\">\n</code></pre>\n<blockquote>\n<p>As an alternative to Animate.css you can always do animations with JavaScript.</p>\n</blockquote>\n<p><ad-incontent></ad-incontent></p>\n<p>After this step, you will have access to every animation that is included in the library. To call an animation from the library on an element, you just need to give it the class <em>animated</em> space and then to put the name of the desired animation. You can find the list with the animation names <a href=\"https://daneden.github.io/animate.css/\"><em>here</em></a>.</p>\n<p>For example, to use the \"bounce\" animation, you just need to do the following:</p>\n<pre><code class=\"language-html\">&#x3C;div class=\"animated bounce\">Hello World&#x3C;/div>\n</code></pre>\n<p>After you reload the page, you will see that the div element which we added in our exercise that will complete the bounce animation. But what if we want to do something like animate elements when the button is clicked or after some particular action done by the user, in most of the cases we are adding animations after a particular event. For completing that you will need just a little JavaScript for triggering the click event and also adding the classes to the desired element. </p>\n<p>For example, let's say that this is the HTML:</p>\n<pre><code class=\"language-html\">&#x3C;button>Button&#x3C;/button>\n&#x3C;section>\nSome random text...\n&#x3C;/section>\n</code></pre>\n<p>What you want to do here is to animate the section using the fade animation, for example, when the user clicks on the button. To do this, first, you need to give it an opacity of 0, and after that, you just need to add the classes dynamically with JavaScript, like in code the example below:</p>\n<p><ad-incontent></ad-incontent></p>\n<pre><code class=\"language-javascript\">$('button').click(function() {\n  $('section').addClass('animated fadeInLeft');\n});\n</code></pre>\n<p>You can also modify the speed of the animations in your CSS:</p>\n<pre><code class=\"language-css\">.animated {\n  -webkit-animation-duration: 500ms;\n  -moz-animation-duration: 500ms;\n  animation-duration: 500ms;\n}\n</code></pre>\n<p><ad-incontent></ad-incontent></p>\n<p>It is also possible to change the delay time in the animation and the count of how many times it is played using the animation-delay and animation-iteration-count. </p>\n<p>You can also perform animation for the transition out after the first animation ends. To do this you need to use the one event and attach it to the end of the animation and simply add the class of the animation we want to use. You can also add a delay class that will allow you to have a delay between fade in and fade out.</p>\n<pre><code class=\"language-javascript\">$('section').one('webkitAnimationEnd mozAnimationEnd MSAnimationEnd oanimationend animationend', function() {\n  $('section').addClass('delay fadeOutRight');\n});\n</code></pre>\n<p>For the CSS part of the code you simply need to add:</p>\n<pre><code class=\"language-css\">.delay {\n  -animation-delay: 1s;\n  -webkit-animation-delay: 1s;\n  -moz-animation-delay: 1s;\n}\n</code></pre>\n<p>After you refresh the page, you can see the fade-in animation, and after one second the fade-out animation too.</p>\n<blockquote>\n<p>CSS animations in the Animate.css have cross-browser support for popular browsers.</p>\n</blockquote>\n<h2>Conclusion</h2>\n<p>For everyone that likes to use CSS animations, knowledge of Animate.css can be essential to make things easy, smooth and simple. You can find the Animate.css on GitHub <a href=\"https://daneden.github.io/animate.css/\"><em>here</em></a>. Thanks for reading, if you find this article helpful please share it.</p>","frontmatter":{"path":"/animate-css/","date":"2020-01-15T12:35:00.619Z","title":"How to do CSS Animations with Animate.css","author":"Aleksandar Vasilevski","image":"/assets/css.jpg","category":"CSS","tags":"#css #html #animations","featured":false}}},{"node":{"id":"35b620c2-8742-5c2c-b47e-e132e3525847","html":"<p><img src=\"/assets/cover/javascript.png\" alt=\"javascript-logo\"></p>\n<p>Every web developer has probably come across to of JavaScript map() and forEach(), two of the most widely used methods in programming. In this article, we will discuss the map() and forEach() method, the differences and usages between two in the JavaScript programming language.</p>\n<h2>Map and ForEach Definition</h2>\n<ol>\n<li>map() - creates a new array with the results of calling a provided function on every element in the array.</li>\n<li>forEach() - executes a provided function once for each array element.</li>\n</ol>\n<p>Now let's understand what is going on in these two statements.</p>\n<p><ad-incontent></ad-incontent></p>\n<p>The <code>map()</code> method calls a provided function on every element that it is in the array. The difference from the <code>forEach()</code> method is that the <code>map()</code> method utilizes return values and also returns a new array of the same size. </p>\n<p>The <code>forEach()</code> method doesn't return anything, but it simply calls a provided function on every element in the array, also this callback can mutate the calling array.  </p>\n<p>Understanding from definitions can be a bit difficult, now let's see some code examples.</p>\n<p>Let's say we have an array with the name \"exampleList\" and perform both the <strong>map</strong> and the <strong>forEach</strong> methods on this array, and see the differences between these two methods at the end.</p>\n<pre><code class=\"language-javascript\">let exampleList = [1, 2, 3, 4, 5]\n</code></pre>\n<h3>Array.prototype.map() Example</h3>\n<pre><code class=\"language-javascript\">exampleList.map(num => {\n    return num * 2;\n});\n</code></pre>\n<p>In the code above, we are doing nothing more just multiplying each element of the \"listArray\" with the 2, which at the end we have a new array called \"mapListResult\", having the same size as the previous one.</p>\n<p><strong>Result:</strong></p>\n<pre><code class=\"language-javascript\">2, 4, 6, 8, 10\n</code></pre>\n<h3>Array.prototype.forEach() Example</h3>\n<pre><code class=\"language-javascript\">exampleList.forEach((num, index) => {\n    return exampleList[index] = num * 2;\n});\n</code></pre>\n<p>In the code above we are doing the same thing as with the <code>map()</code> method but this time we are using the <code>forEach()</code> method.</p>\n<pre><code class=\"language-javascript\">2, 4, 6, 8, 10\n</code></pre>\n<h2>When to Use Map and ForEach Method</h2>\n<p>We have seen the implementation between these two methods, which will give you a better picture of both of them. Now about the usage, if your only purpose is to iterate the array and perform some operations on the elements, it is better to use the <code>forEach()</code> method. On the other hand, if you need to transform the elements from the array then you should use the <code>map()</code> method, also if you want to filter the data after modifying it, <code>map()</code> method is better option, because it will create a new array, and you can perform operations on it. </p>\n<blockquote>\n<p>If you like functional programming, using <code>map()</code> method may be preferred, this is because the ForEach will affect and changes the original array, where Map returns an entirely new array without modifying it.</p>\n</blockquote>\n<h2>Which one is faster Map or ForEach Method</h2>\n<p>In development, we should always keep in mind the performance or speed factor for performing some operation of the code. Now let's see which one is the faster the <code>map()</code> or <code>forEach()</code> method.</p>\n<p><code>map()</code> method is faster then <code>forEach()</code> method in terms of speed. In practice you shouldn't be using the <code>forEach()</code> method until the <code>map()</code> method cannot do the required task.</p>\n<blockquote>\n<p>Both <code>map()</code> and <code>forEach()</code> methods are worse then the standard <code>for()</code> loop when the speed is considered. But sometimes we may want to sacrifice speed for better code readability (cleaner code).</p>\n</blockquote>\n<p><ad-incontent></ad-incontent></p>\n<h2>Conclusion</h2>\n<p>We have seen implementation and key differences between the Map and ForEach methods in JavaScript, I hope now you understand how and when to use these two methods in your projects. If you find this article helpful to you please share it, and thanks for reading.</p>","frontmatter":{"path":"/javascript-map-vs-foreach/","date":"2020-01-13T12:00:49.619Z","title":"JavaScript Map vs ForEach Method","author":"Aleksandar Vasilevski","image":"/assets/cover/javascript.png","category":"JavaScript","tags":"#javascript","featured":false}}},{"node":{"id":"8a275674-42f5-56dc-ac04-61f8ad6863a4","html":"<p><img src=\"/assets/cover/create-react-app-from-scratch-part-4.png\" alt=\"create-react-app-part-4\"></p>\n<p>This article is part of the ReactJS series, you can find the previous part on the following link: <a href=\"https://www.codespot.org/create-react-app-from-scratch-part-3/\" style=\"font-weight:bold; text-transform:uppercase; color:#ff7a59;\">Create React App From Scratch Part 3: Working with Props</a>.</p>\n<h2>How to Style React Component</h2>\n<p>In the last parts of the series, we cover a lot about React components, but we have not touched the styling of the React components at all. In this part, we will see how we can style React components. There are a couple of ways to style React components, where all of them have some pros and cons. Let's see some of the ways to style React components.</p>\n<p><ad-incontent></ad-incontent></p>\n<blockquote>\n<p>In this part, we are going to use some basics of the CSS FlexBox for additional styling of the React components. If you are not familiar with CSS FlexBox, you can check these two great books linked below to learn more.</p>\n</blockquote>\n<p><a href=\"https://www.amazon.com/gp/product/1491918055/ref=as_li_tl?ie=UTF8&camp=1789&creative=9325&creativeASIN=1491918055&linkCode=as2&tag=aleksandarvas-20&linkId=adeadea78787d5e8c53cddcc45cd6cc6\" style=\"font-weight:bold; text-decoration:underline; color:#ff7a59;\">CSS: The Missing Manual</a></p>\n<p><a href=\"https://www.amazon.com/gp/product/1449393195/ref=as_li_tl?ie=UTF8&camp=1789&creative=9325&creativeASIN=1449393195&linkCode=as2&tag=aleksandarvas-20&linkId=eb68c64da42179938bf38b3dbf0fe0c8\" style=\"font-weight:bold; text-decoration:underline; color:#ff7a59;\">CSS: The Definitive Guide: Visual Presentation for the Web</a></p>\n<h3>Using App.css</h3>\n<p>The first way to style a React component is to use the App.css file in the <code>src</code> folder. App.css is a global CSS file that will affect the style of all of the components in your React project. Pros for using App.css is that you can use pseudo selectors. The cons are that the file can become big and messy, and we cannot change styling dynamically (to use conditionals for example).</p>\n<h3>Inline Styling</h3>\n<p>We can also use React inline styling, to do this we just need to declare style property on an element and set the style, but for cleaner code instead of writing the CSS on the line where the property is declared we will just pass the variable, like this:</p>\n<pre><code class=\"language-JSX\">const style = {\n    backgroundColor:'white',\n    padding:'8px',\n    border:'1px solid red'\n    cursor:'pointer'\n}\n\n&#x3C;button style={style} onClick={this.doSomething}>Some Button&#x3C;/button>\n</code></pre>\n<p>Pros for inline styling is that we can use conditionals if we need them in some cases when we want to set the style that depends on some value. This is possible because JSX is also JavaScript. The cons are that we cannot use pseudo selectors here.</p>\n<h3>CSS Modules</h3>\n<p>The third way to style React components it is with the CSS modules. CSS module is a file in which all class names and animations are scoped locally-e.g., every JS file will have CSS file which is scoped to that file. Later in this series, we will start using the CSS Modules.</p>\n<p><ad-incontent></ad-incontent></p>\n<h2>Styling React Components</h2>\n<p>Now as we have seen how we can style React components, before we start we will install React Bootstrap, to install React Bootstrap we will use the following commands:</p>\n<pre><code class=\"language-Shell\">npm install react-bootstrap bootstrap\nnpm install bootstrap\n</code></pre>\n<blockquote>\n<p>React Bootstrap is the same as the regular bootstrap just it is implemented on a different way.</p>\n</blockquote>\n<p>Before we can use React Bootstrap we must add it on top of the src/index.js file.</p>\n<pre><code class=\"language-JSX\">import 'bootstrap/dist/css/bootstrap.min.css';\n</code></pre>\n<p>Now after everything is set up correctly we can start styling our first React component the Cryptocurrency component, which is the component for every item (coin) on the list.</p>\n<pre><code class=\"language-JSX\">const styleCryptocurrency = {\n  backgroundColor: \"white\",\n  border: \"solid 1px gray\",\n  padding: \"10px\",\n  cursor: \"pointer\",\n  display: \"flex\",\n  flexDirection: \"row\",\n}\n\nconst styleName = {\n  padding: \"0 5px\",\n  flex: \"1\",\n  color: \"#004e92\",\n}\n\nconst styleSymbol = {\n  fontWeight: \"bold\",\n  color: \"grey\",\n  padding: \"0 5px\",\n  marginLeft: \"20px\",\n  flex: \"6\"\n}\n\nconst stylePrice = {\n  padding: \"0 5px\",\n}\n\nconst cryptocurrency = (props) => (\n  &#x3C;div style={styleCryptocurrency}>\n    &#x3C;div style={styleName}>{props.name}&#x3C;/div>\n    &#x3C;div style={styleSymbol}>{props.symbol}&#x3C;/div>\n    &#x3C;div style={stylePrice}>{props.price}&#x3C;/div>\n  &#x3C;/div>\n);\n</code></pre>\n<p>Here we have added a couple of basic stylings for the component itself, name, symbol, and the price.\nAnd also we want to style our CryptoCurrencies component which is the container for the Cryptocurrency components.</p>\n<pre><code class=\"language-JSX\">import {Container} from 'react-bootstrap';\n\nclass CryptoCurrencies extends Component {\n  render(){\n    return(\n      &#x3C;Container>\n        &#x3C;Cryptocurrency name=\"Bitcoin\" symbol=\"BTC\" price=\"7000\"/>\n        &#x3C;Cryptocurrency name=\"Ethereum\" symbol=\"ETC\" price=\"125\"/>\n        &#x3C;Cryptocurrency name=\"XRP\" symbol=\"XRP\" price=\"0.1\"/>\n        &#x3C;Cryptocurrency name=\"Bitcoin Cash\" symbol=\"BCH\" price=\"180\"/>\n      &#x3C;/Container>\n    );\n  }\n}\n</code></pre>\n<p>Here we have imported the Container from the React Bootstrap library, and we have replaced the parent div with the Container which under the hood is nothing more thana div with class container. When we see the app now it is still not looking great but it will be improved over time in the next parts.</p>\n<p><ad-incontent></ad-incontent></p>\n<h2>Part Overview</h2>\n<p>In this part, we have seen basics about how we can style React components also a couple of ways how we can do that, and when which one is best to be used. Later in the series, we will come back at styling React components when we will have dynamic data.</p>\n<p>If you are interested to learn React much deeper, I recommend you to read this book: </p>\n<p><a href=\"https://www.amazon.com/gp/product/B077HJFCQX/ref=as_li_tl?ie=UTF8&camp=1789&creative=9325&creativeASIN=B077HJFCQX&linkCode=as2&tag=aleksandarvas-20&linkId=6c518448e9ae3041011a1dfc8cea8e00\" style=\"font-weight:bold; text-decoration:underline; color:#ff7a59;\">The Road to learn React: Your journey to master plain yet pragmatic React.js</a></p>\n<p>If you prefer a video course, I highly recommend you to take a look at this course on Udemy:</p>\n<p><a href=\"https://click.linksynergy.com/link?id=LFcSQV4ezac&offerid=507388.1362070&type=2&murl=https%3A%2F%2Fwww.udemy.com%2Fcourse%2Freact-the-complete-guide-incl-redux%2F\"><IMG border=0 src=\"https://i.udemycdn.com/course/480x270/1362070_b9a1_2.jpg\" ><div >React - The Complete Guide (incl Hooks, React Router, Redux)</div></a><IMG border=0 width=1 height=1 src=\"https://ad.linksynergy.com/fs-bin/show?id=LFcSQV4ezac&bids=507388.1362070&type=2&subid=0\" ></p>\n<p>The code from the course is available on GitHub: <a href=\"https://github.com/AleksandarVasilevski/create-react-app-from-scratch\"><strong>Create React App From Scratch</strong></a> on the branch: 04-styling-components.</p>\n<p>Next part: <a href=\"https://www.codespot.org/create-react-app-from-scratch-part-5/\" style=\"font-weight:bold; text-transform:uppercase; color:#ff7a59;\">Create React App From Scratch Part 5: Http Requests</a></p>","frontmatter":{"path":"/create-react-app-from-scratch-part-4/","date":"2020-01-09T21:10:49.619Z","title":"Create React App From Scratch Part 4: Styling Components","author":"Aleksandar Vasilevski","image":"/assets/cover/create-react-app-from-scratch-part-4.png","category":"React","tags":"#react #js #javascript #createReactAppFromScratch #components #style #css","featured":false}}},{"node":{"id":"888352dd-3008-5119-b19a-5739d6f32385","html":"<p><img src=\"/assets/cover/productivity-room.jpg\" alt=\"nodejs-heroku-logo\"></p>\n<p>To stay productive as a programmer and developer is not an easy task. It's a stressful job that can make you lose focus very fast or make you feel drained, the understanding of how you can focus on your work, and deal with distractions, can help you a lot in making the most out of your working hours. In this article, we have made a list of the best productivity tips for developers and programmers that should follow for the best productivity.</p>\n<p><ad-incontent></ad-incontent></p>\n<h2>1. Start With The Most Difficult Task</h2>\n<p>Almost every developer has some hierarchy of daily tasks in some sort of to-do list. If you focus on simply checking off to-do list items, you’ll end up with a mix of important and less important tasks completed. This habit can also expose you to spending the whole day checking off easy, less important to-dos instead of finishing some of the hard stuff. Instead of doing this, you should spend a couple of minutes at the beginning of your workday to chose a couple of most difficult tasks and do them, no matter what, you need to finish by the end of the day.</p>\n<h2>2. Break Down Tasks Into Smaller Tasks</h2>\n<p>Most of the way then we see some hard task it looks too daunting and we want to skip it somehow, you look at the task and think “I don’t even know where to start.”  I bet you hear about divide and conquer algorithm, here we can reuse the same principle for the work-related tasks. For example, if you have a task that says \"write a blog post on productivity\" you can break that task into smaller parts like: \"look for keywords related to productivity\", \"Find 5 examples of productivity posts\", etc.</p>\n<h2>3. Eliminate Distractions</h2>\n<p>Distractions are the biggest enemy of productivity not just for developers but in every profession, so you need to find a way to ignore them as much as it is possible. For example, often checking work-related stuff like emails, chats, etc, can be seen as work-related but spending too much time on these things will make you not finish anything at the end of the day. So the best thing is to make some patterns, for example, to check emails two times a day, switching off notifications from social channels, etc</p>\n<iframe style=\"width:120px;height:240px;\" marginwidth=\"0\" marginheight=\"0\" scrolling=\"no\" frameborder=\"0\" src=\"//ws-na.amazon-adsystem.com/widgets/q?ServiceVersion=20070822&OneJS=1&Operation=GetAdHtml&MarketPlace=US&source=ac&ref=tf_til&ad_type=product_link&tracking_id=aleksandarvas-20&marketplace=amazon&region=US&placement=0143126563&asins=0143126563&linkId=85a0e968eaf0e7ebf6cab2a753a7bb14&show_border=false&link_opens_in_new_window=false&price_color=333333&title_color=0066c0&bg_color=ffffff\">\n    </iframe>\n<iframe style=\"width:120px;height:240px;\" marginwidth=\"0\" marginheight=\"0\" scrolling=\"no\" frameborder=\"0\" src=\"//ws-na.amazon-adsystem.com/widgets/q?ServiceVersion=20070822&OneJS=1&Operation=GetAdHtml&MarketPlace=US&source=ac&ref=tf_til&ad_type=product_link&tracking_id=aleksandarvas-20&marketplace=amazon&region=US&placement=0307465357&asins=0307465357&linkId=42e8207cfd796d1380c78554b0f3f8f6&show_border=false&link_opens_in_new_window=false&price_color=333333&title_color=0066c0&bg_color=ffffff\">\n    </iframe>\n<h2>4. Take Breaks</h2>\n<p>Nobody can stay focused for eight hours a day without taking breaks, not even highly focused people. There are many kinds of <a href=\"https://www.tandfonline.com/doi/abs/10.1080/001401397188396\"><em>research</em></a> done that are showing that taking a break at least a few minutes long can help you to feel more focused and come up with new ideas. There is one famous technique for taking breaks called Pomodoro Technique that uses a tomato-shaped timer to measure time. It works with 25 minutes time blocks with 5 minute short breaks and 10 minutes long breaks. The Pomodoro Technique is so much popular in the developer community that there are even Pomodoro Apps you can use it. </p>\n<h2>5. Find The Best Code Editor</h2>\n<p>Programmer productivity starts with a good code editor. There are great Code Editors or IDE's out there, and it is not easy to tell which one is the best, and also it depends on your needs. To find the best code editor for you, it is best to try different code editors to see which one fits you the best. When searching for the best code editor there are few things to remember:</p>\n<ul>\n<li>Programming languages that you are using. The code editor should have syntax highlighting for the languages you are using. Some popular code editors also offer syntax highlighters for frameworks too (Sometimes if syntax highlighting is not available you may download a plugin).</li>\n<li>If you work with technologies like Git (which you should!) you might need built-in Git functionalities for committing your code directly to GitHub, etc.</li>\n<li>Code Editor with adequate themes and plugins.</li>\n</ul>\n<p><ad-incontent></ad-incontent></p>\n<h2>6. Automate Repetitive Tasks</h2>\n<p>Today automating repetitive tasks is a must as a developer or programmer. In the development phase, this can be a lot of things like learning common keyboard shortcuts in your code editor or IDE or refactoring the name of a variable or function in more than one place (which are connected with the last tip about the best code editor). Knocking these things from your work-flow can save you lots of energy and time, and make you much better on focusing on other more important things.</p>\n<h2>7. Schedule Your Tasks in Advance</h2>\n<p>Scheduling your tasks in advance can greatly improve your productivity. You can create a to-do list for your tasks using to-do apps like <a href=\"https://play.google.com/store/apps/details?id=com.aleksandarvasilevski.notes\"><em>Notes - Notepad and Memo App</em></a>. When using task scheduling apps, too much complexity can even lead to a loss of productivity. So the app should be simple enough and still useful like the app linked above, it is easy to get lost in some big apps in doing very simple things.</p>\n<h2>8. Use the Command Line</h2>\n<p>One of the best habits for every programmer is to use the CLI (Command Line Interface) instead of GUI (Graphical User Interface), this will greatly speed up the development process and at the end, good knowledge of the CLI commands is an important programming skill that will greatly improve your market value when you will be looking for a new programming related job and will make your work-flow look much more confident and professional.</p>\n<p><ad-incontent></ad-incontent></p>\n<h2>Conclusion</h2>\n<p>If you follow these productivity tips, you can make your working hours much more efficient and also improve your development workflow at the same time. At start picking, new habits can be hard but quickly will become natural. Experimenting new things is key in productivity when you try new thing that or tool it is not working on you skip it and move to the next one, until you find the best tools and techniques.</p>\n<p>I will highly recommend you to read these two great books about productivity:</p>\n<p><a href=\"https://www.amazon.com/gp/product/0143126563/ref=as_li_tl?ie=UTF8&camp=1789&creative=9325&creativeASIN=0143126563&linkCode=as2&tag=aleksandarvas-20&linkId=fffdd5cada6f50131178c4f5541f8113\" style=\"font-weight:bold; color:#ff7a59;\">Getting Things Done: The Art of Stress-Free Productivity</a></p>\n<p><a href=\"https://www.amazon.com/gp/product/0307465357/ref=as_li_tl?ie=UTF8&camp=1789&creative=9325&creativeASIN=0307465357&linkCode=as2&tag=aleksandarvas-20&linkId=0f2a49babb0d808a3d9d3d3257ad5ee2\" style=\"font-weight:bold; color:#ff7a59;\">The 4-Hour Workweek: Escape 9-5, Live Anywhere, and Join the New Rich</a></p>","frontmatter":{"path":"/productivity-tips-for-developers-and-programmers/","date":"2020-01-05T14:30:00.619Z","title":"8 Best Productivity Tips for Developers and Programmers","author":"Aleksandar Vasilevski","image":"/assets/cover/productivity-room.jpg","category":"Tips","tags":"#tips #productivity","featured":false}}},{"node":{"id":"d0cc9eff-b91f-58a4-aa93-2cfe00cfb46e","html":"<p><img src=\"/assets/cover/nodejs-heroku.png\" alt=\"nodejs-heroku-logo\"></p>\n<p>In the last couple of years, Node.js has become one of the most preferred technology for building backend services, with the rise of microservices, Node.js has become even more desirable. That is because it is fast, stable, and almost every web developer today know JavaScript. The last phase of building the Node.js app is to find good and cheap hosting. In this article, we will see how to deploy Node app to Heroku.</p>\n<p><ad-incontent></ad-incontent></p>\n<h2>What is Heroku</h2>\n<p>Heroku is a cloud application platform that allows developers to deploy, manage and scale modern apps. Heroku platform is elegant, flexible, and easy to use, which in the end, it is offering to the developers the simplest path to get their apps on the market. Heroku officially supports most of the programming language used today for building backend services like Node.js, Ruby, Java, PHP, Python, Go, Scala, Clojure and in addition to the officially supported languages, you can use any language that runs on Linux with Heroku via a third-party build-pack.</p>\n<blockquote>\n<p>In this article we are using the Node.js app for the examples, but the process is very similar if you are using other programming languages or frameworks as well.</p>\n</blockquote>\n<h2>Node App Deployment on Heroku</h2>\n<p>To deploy node app on Heroku, firstly you need a Heroku account, which you can create for free in a couple of minutes. When you sign in to the Heroku, on the first screen you will see all your deployed applications and a button named new, which is what we are looking for, and in the dropdown menu, we need to select create a new app, as in the picture below. </p>\n<p><img src=\"/assets/heroku/heroku-admin-01.jpg\" alt=\"heroku-example-1\"></p>\n<p>The next step in the app deployment is the create a new app screen, where you need to pick a name for the app and chose the region where the app will be hosted. as it is shown below.</p>\n<p><ad-incontent></ad-incontent></p>\n<blockquote>\n<p>Chosing proper region is important as will reduce the lag in the app</p>\n</blockquote>\n<p><img src=\"/assets/heroku/heroku-admin-02.jpg\" alt=\"nodejs-example-2\"></p>\n<p>In this step, you have a much detailed screen, where you need to connect the repository with your node.js application with the Heroku. There are a couple of ways to do that, one is to use Heroku Git, but the preferred option is to have the Node.js application on GitHub and to connect the Heroku with the repository. To do that you need to select connect to GitHub, like in the example below.</p>\n<p><img src=\"/assets/heroku/heroku-admin-03.jpg\" alt=\"nodejs-example-2\"></p>\n<p>When you select the connect to GitHub option you will need to search for the repository on GitHub after that new options will appear on the screen when you need to choose a branch to deploy, and here you can enable automatic deploys from GitHub, which will update automatically when the branch is updated. When everything is ready you just need to press the deploy branch button, and if everything is ok with the app, after a couple of seconds the message \"Your app was successfully deployed\" should appear, which means your application is live.</p>\n<p>If there are problems during the deployment you can check the activity tab on the top which has log messages. In the settings tab, you can Config Vars, where you can set your environment variables for production.</p>\n<p><ad-incontent></ad-incontent></p>\n<h2>Conclusion</h2>\n<p>As we can see from the steps above, deployment of the app on Heroku is not hard at all, it can be done in a couple of minutes. There are many more tools that the Heroku platform offers to the developers, there are priced packages too, which are also great if you have a bigger app. In the end, I hope you can understand how to deploy the Node app to Heroku if you find this article useful please share it.</p>","frontmatter":{"path":"/how-to-deploy-node-app-to-heroku/","date":"2020-01-02T11:00:00.619Z","title":"How to Deploy Node App to Heroku","author":"Aleksandar Vasilevski","image":"/assets/cover/nodejs-heroku.png","category":"Nodejs","tags":"#nodejs #expressjs #javascript #heroku","featured":false}}},{"node":{"id":"1d433663-12eb-57fe-b066-1201747247e1","html":"<p><img src=\"/assets/cover/create-react-app-from-scratch-part-3.png\" alt=\"create-react-app-part-3\"></p>\n<p>This article is part of the ReactJS series, you can find the previous part on the following link: <a href=\"https://www.codespot.org/create-react-app-from-scratch-part-2/\" style=\"font-weight:bold; text-transform:uppercase; color:#ff7a59;\">Create React App From Scratch Part 2: Into Components</a>.</p>\n<h2>Adding Cryptocurrency Component and Accessing Props</h2>\n<p>In the last part, we talked a lot about React components and we have added two of them. Now we need to add one more React component, the cryptocurrency component, which will be rendered for every cryptocurrency we have on the list. We will nest all of the cryptocurrency components inside the container component called <code>CryptoCurrencies.js</code>.\nTo start with it, we will create a folder inside the components folder called Cryptocurrency, we are creating the folder here because this component will be presentational only (it's not going to manage any state). Inside our new folder, we will make a new React component called <code>CryptoCurrencies.js</code>, which will be again a functional component. Let's see how it looks in the next example.</p>\n<p><ad-incontent></ad-incontent></p>\n<pre><code class=\"language-JSX\">import React from 'react';\n\nconst cryptocurrency = (props) => (\n  &#x3C;div>\n    &#x3C;span>{props.name}&#x3C;/span> | &#x3C;span>{props.symbol}&#x3C;/span> | &#x3C;span>{props.price}&#x3C;/span>\n  &#x3C;/div>\n);\n\nexport default cryptocurrency;\n</code></pre>\n<p>As you can see now we have added three span elements, which are temporary just for better formating, and inside we are using the props to access the data passed from the parent component which we will be adding next.</p>\n<blockquote>\n<p>Note: The props argument is just properties passed to this component, and you can name it how you want to, but the name \"props\" is used as default.</p>\n</blockquote>\n<h2>Passing Props</h2>\n<p>Until now our components don't do anything in our app, also they are not holding any data, now we will change this. Before we are showing dynamic data fetched from a Rest API, we will test our app with dummy data. As we talked in the last part, our <code>Cryptocurrencies.js</code> component will be responsible for storing the data. Let's add some dummy data and see how it looks like in the next example.</p>\n<p><ad-incontent></ad-incontent></p>\n<pre><code class=\"language-JSX\">import React, {Component} from 'react';\nimport Cryptocurrency from '../../components/Cryptocurrency/Cryptocurrency'\n\nclass CryptoCurrencies extends Component {\n  render(){\n    return(\n      &#x3C;div>\n        &#x3C;Cryptocurrency name=\"Bitcoin\" symbol=\"BTC\" price=\"7000\"/>\n        &#x3C;Cryptocurrency name=\"Ethereum\" symbol=\"ETC\" price=\"125\"/>\n        &#x3C;Cryptocurrency name=\"XRP\" symbol=\"XRP\" price=\"0.1\"/>\n        &#x3C;Cryptocurrency name=\"Bitcoin Cash\" symbol=\"BCH\" price=\"180\"/>\n      &#x3C;/div>\n    );\n  }\n}\n\nexport default CryptoCurrencies;\n</code></pre>\n<p>Firstly we have added new import which is the new component we have created at the beginning called cryptocurrency, and inside the cryptocurrencies container, we have added a couple of new components with some dummy data that we will render inside them, which they are accessing through props.</p>\n<blockquote>\n<p>Note: In React when state changes, the component will re-render and will show the new state. </p>\n</blockquote>\n<p>Now our components tree look like this:</p>\n<p><img src=\"/assets/samples/create-react-app-from-scratch-components-tree-3.png\" alt=\"component-tree\"></p>\n<blockquote>\n<p>Note: For now, our components have just a basic look, but we will style them later in the series.</p>\n</blockquote>\n<p><ad-incontent></ad-incontent></p>\n<h2>Part Overview</h2>\n<p>In this part, we have seen more on components to React as we created one more component called Cryptocurrency. We have also seen what is props and how we can pass it or access inside of our components.</p>\n<p>To learn React much deeper, I recommend you to read this book: </p>\n<p><a href=\"https://www.amazon.com/gp/product/B077HJFCQX/ref=as_li_tl?ie=UTF8&camp=1789&creative=9325&creativeASIN=B077HJFCQX&linkCode=as2&tag=aleksandarvas-20&linkId=6c518448e9ae3041011a1dfc8cea8e00\" style=\"font-weight:bold; text-transform:uppercase; color:#ff7a59;\">The Road to learn React: Your journey to master plain yet pragmatic React.js</a>.</p>\n<p>If you prefer a video course, I highly recommend you to take a look at this course on Udemy:</p>\n<p><a href=\"https://click.linksynergy.com/link?id=LFcSQV4ezac&offerid=507388.1362070&type=2&murl=https%3A%2F%2Fwww.udemy.com%2Fcourse%2Freact-the-complete-guide-incl-redux%2F\"><IMG border=0 src=\"https://i.udemycdn.com/course/480x270/1362070_b9a1_2.jpg\" ><div >React - The Complete Guide (incl Hooks, React Router, Redux)</div></a><IMG border=0 width=1 height=1 src=\"https://ad.linksynergy.com/fs-bin/show?id=LFcSQV4ezac&bids=507388.1362070&type=2&subid=0\" ></p>\n<p>The code from the course is available on GitHub: <a href=\"https://github.com/AleksandarVasilevski/create-react-app-from-scratch\"><strong>Create React App From Scratch</strong></a> on the branch: 03-working-with-props.</p>\n<p>Next part: <a href=\"https://www.codespot.org/create-react-app-from-scratch-part-4/\" style=\"font-weight:bold; text-transform:uppercase; color:#ff7a59;\">Create React App From Scratch Part 4: Styling Components</a></p>","frontmatter":{"path":"/create-react-app-from-scratch-part-3/","date":"2019-12-25T23:00:49.619Z","title":"Create React App From Scratch Part 3: Working with Props","author":"Aleksandar Vasilevski","image":"/assets/cover/create-react-app-from-scratch-part-3.png","category":"React","tags":"#react #js #javascript #createReactAppFromScratch #components","featured":false}}},{"node":{"id":"1791b62b-2e73-5980-9d1f-93a77471e4d9","html":"<p><img src=\"/assets/cover/head-first-java.jpg\" alt=\"head-first-java-cover\"></p>\n<p>Learning a new Programming language is not an easy task, and to learn a new language the best way is to read a book. If you check the Top 50 books on Amazon in the Computers and Internet (C&#x26;I) section you will for sure find a book from the Head First series. Head First Java written by Kathy Sierra, is a book about the Java Programming Language, first published in 2003, since then it is one of the best books to start learning the Java Programming Language. As with the other books in the series Head First. The format of every Head First book in the series is somewhat different from the other books, and that is same for the Head First Java which is rich with pictures, quizzes, tips and tricks to make the learning of the particular topic much easier.</p>\n<p><ad-incontent></ad-incontent></p>\n<p>The learning approach in the book is mostly object-oriented, this is great because if you are a beginner you will gain the right mindset on object-oriented programming. The book is a little under 700 pages, and there are 18 chapters.</p>\n<h2>Topics covered</h2>\n<p>Head First Java covers every aspect of the Java programming language for starters. It starts with some basic topics around the programming and from one to another chapter it goes on more complex things.</p>\n<ul>\n<li>\n<ol>\n<li>Breaking the surface - It is mostly an introduction.</li>\n</ol>\n</li>\n<li>\n<ol start=\"2\">\n<li>A Trip to Objectville - Covers the idea behind object-oriented vs procedural programming.</li>\n</ol>\n</li>\n<li>\n<ol start=\"3\">\n<li>Know Your Variables - It explains the variables in deep.</li>\n</ol>\n</li>\n<li>\n<ol start=\"4\">\n<li>How Objects Behave - Covers the topic around the encapsulation, methods, getters, setters.</li>\n</ol>\n</li>\n<li>\n<ol start=\"5\">\n<li>Extra-Strength Methods - Focuses on procedural programming, loops, etc.</li>\n</ol>\n</li>\n<li>\n<ol start=\"6\">\n<li>Using the Java Library - As the name says it is focused on the usage of the Java library.</li>\n</ol>\n</li>\n<li>\n<ol start=\"7\">\n<li>Better Living in Objectville - This chapter covers the inheritance in object-oriented programming like is-a has-a relationships.</li>\n</ol>\n</li>\n<li>\n<ol start=\"8\">\n<li>Serious Polymorphism - Explains polymorphism in depth.</li>\n</ol>\n</li>\n<li>\n<ol start=\"9\">\n<li>Life and Death of an Object - Covers constructors, destructors, superclasses, etc.</li>\n</ol>\n</li>\n<li>\n<ol start=\"10\">\n<li>Numbers Matter - More on objects, using the math class.</li>\n</ol>\n</li>\n<li>\n<ol start=\"11\">\n<li>Risk Behavior - Deals with exceptions and exception handling.</li>\n</ol>\n</li>\n<li>\n<ol start=\"12\">\n<li>A Very Graphics - Explains the Graphical User Interface (GUI).</li>\n</ol>\n</li>\n<li>\n<ol start=\"13\">\n<li>Work on Your Swing - More on the Graphical User Interface.</li>\n</ol>\n</li>\n<li>\n<ol start=\"14\">\n<li>Saving Objects - Focuses on object serialization and file handling.</li>\n</ol>\n</li>\n<li>\n<ol start=\"15\">\n<li>Making a Connection - Covers networking, sockets, TCP, concurrency, also topics like threading, locking, synchronization, etc.</li>\n</ol>\n</li>\n<li>\n<ol start=\"16\">\n<li>Data structures - Covers the fundamentals of data structures.</li>\n</ol>\n</li>\n<li>\n<ol start=\"17\">\n<li>Release Your Code - Covers the deployment, JAR and JWS</li>\n</ol>\n</li>\n<li>\n<ol start=\"18\">\n<li>Distributed Computing - Looks into distributed computing via Remote Invocation and Jini.</li>\n</ol>\n</li>\n</ul>\n<iframe style=\"width:120px;height:240px;margin:auto;display:block;\" marginwidth=\"0\" marginheight=\"0\" scrolling=\"no\" frameborder=\"0\" src=\"//ws-na.amazon-adsystem.com/widgets/q?ServiceVersion=20070822&OneJS=1&Operation=GetAdHtml&MarketPlace=US&source=ac&ref=tf_til&ad_type=product_link&tracking_id=aleksandarvas-20&marketplace=amazon&region=US&placement=0596009208&asins=0596009208&linkId=524137f220803dce94aa06811f09c2f8&show_border=false&link_opens_in_new_window=false&price_color=333333&title_color=0066c0&bg_color=ffffff\">\n    </iframe>\n<h2>Conclusions</h2>\n<p>Overall head First Java has a heavy emphasis on object-oriented philosophy. It is a great book to get started with Java, but as we saw in the topic above, as we go from one to another it also covers some of the more advanced topics, which means it offers much more than just introduction. </p>\n<p>You can find the Head First Java on the link below on Amazon:</p>\n<p><a href=\"https://www.amazon.com/gp/product/0596009208/ref=as_li_tl?ie=UTF8&camp=1789&creative=9325&creativeASIN=0596009208&linkCode=as2&tag=aleksandarvas-20&linkId=551bdff54f7198ec6110f1d32a48875c\" style=\"font-weight:bold; color:#fff; font-size:22px; background:#ff7a59; padding:8px 16px; border-radius:8px;\">Head First Java, 2nd Edition</a></p>\n<p><a target=\"_blank\"  href=\"https://www.amazon.com/gp/product/0596009208/ref=as_li_tl?ie=UTF8&camp=1789&creative=9325&creativeASIN=0596009208&linkCode=as2&tag=aleksandarvas-20&linkId=9ea25f0eb4adff8c7f7af6f3a75fdcac\"><img border=\"0\" style=\"margin:auto; display:block\" src=\"//ws-na.amazon-adsystem.com/widgets/q?_encoding=UTF8&MarketPlace=US&ASIN=0596009208&ServiceVersion=20070822&ID=AsinImage&WS=1&Format=_SL250_&tag=aleksandarvas-20\" ></a><img src=\"//ir-na.amazon-adsystem.com/e/ir?t=aleksandarvas-20&l=am2&o=1&a=0596009208\" width=\"1\" height=\"1\" border=\"0\" alt=\"\" style=\"border:none !important; margin:0px !important;\" /></p>","frontmatter":{"path":"/review-head-first-java/","date":"2019-12-20T11:40:00.619Z","title":"Head First Java","author":"Aleksandar Vasilevski","image":"/assets/cover/head-first-java.jpg","category":"Books","tags":"#java #book #review","featured":false}}},{"node":{"id":"b8ce4cf6-2744-552d-ad7e-914c47888081","html":"<p><img src=\"/assets/cover/create-react-app-from-scratch-part-2.png\" alt=\"create-react-app-part-2\"></p>\n<p>This article is part of the ReactJS series, you can find the previous part on the following link: <a href=\"https://www.codespot.org/create-react-app-from-scratch-part-1/\" style=\"font-weight:bold; text-transform:uppercase; color:#ff7a59;\">Create React App From Scratch Part 1: Setting Up</a>.</p>\n<h2>React Components</h2>\n<p>In the last lecture, we have mentioned the React components, and we have edited the <code>App.js</code> component. Now let's dive deeper into the components. React is everything about creating components, which are custom Html elements, where later we use them to build our ReactJS application. This <code>App.js</code> component which we saw in the last part of the Create React App From Scratch, is used into the <code>index.js</code> where we render it into the root element. Typically you render one root component, in our case the App component (but we can name it whatever we want) and inside of it, you will nest all other React components. The best thing about React components is that we can reuse them.</p>\n<blockquote>\n<p>Note: You can render normal Html elements instead of React components.</p>\n</blockquote>\n<p><ad-incontent></ad-incontent></p>\n<h3>Defining React Components</h3>\n<p>There are two ways to define a React component. The first way to define component is class-based, where we create a JavaScript class. The other way is function-based, where we create a JavaScript function.</p>\n<pre><code class=\"language-JSX\">import React, {Component} from 'react';\nimport './App.css';\n\nclass App extends Component{\n    render(){\n        return(\n            &#x3C;div className=\"App\">\n              &#x3C;h1>Hello, World!&#x3C;/h1>\n            &#x3C;/div>\n        );\n    }\n}\n\nexport default App;\n</code></pre>\n<p><em>Class-based React component</em></p>\n<p>The first way for creating React components is class-based were at the top we are importing the React and Component from the React library, after that we are creating JavaScript class and then we extend the Component class. Inside the class we have the render method, this method is important because React calls this method to render something on the screen, and inside the render method we are returning (rendering) some code. And at the bottom, we export the App class.</p>\n<blockquote>\n<p>Note: The code inside the components looks like Html but it is called JSX. JSX is JavaScript that looking a bit different.</p>\n</blockquote>\n<pre><code class=\"language-JSX\">import React from 'react';\nimport './App.css';\n\nfunction App() {\n  return (\n    &#x3C;div className=\"App\">\n      &#x3C;h1>Hello, World!&#x3C;/h1>\n    &#x3C;/div>\n  );\n}\n\nexport default App;\n</code></pre>\n<p><em>Function-based React component</em></p>\n<p>The second way for creating React components is function-based, basically is the simple JavaScript function which returns some JSX code, and it is exported at the end. Like in the class component we still need to import the React library at the top of the component, but here we don't need the component import. This is the simplest form, but the recommended way is the ES6 function syntax, which we will be using for creating the next components.</p>\n<blockquote>\n<p>Note: We can do other stuff inside the components like connecting to the internet, doing calculations, listen to events, etc.</p>\n</blockquote>\n<p><ad-incontent></ad-incontent></p>\n<h2>Creating a Layout Component</h2>\n<p>We have seen what are the components, but we still have just one compnent. Now let's start creating more of them. Firstly we will add the layout component, we want to use this layout component as a wrapper. It is fine even if we used the App.js becouse it is the root component. For now we want our component tree to look like this:</p>\n<p><img src=\"/assets/samples/create-react-app-from-scratch-components-tree-1.png\" alt=\"component-tree\"></p>\n<p>To start with, we want to have two new folders inside the src folder, components, and containers. In the components folder, we will be storing the presentational components that are not holding any state (we will look at the state later), and in the containers folder, we will be storing the state full components. Now we are going to create the layout component in the components folder because right now we don't need to manage any state inside of it. Inside components, we are going to create a subfolder named Layout, and inside we will create the <code>Layout.js</code> file. So we have nicely structured components in separate folders. </p>\n<p><ad-incontent></ad-incontent></p>\n<p>Inside the <code>Layout.js</code> we will create a functional component but now we will start using ES6 syntax as I said earlier. Firstly we will import the React library at the top, inside the component, first we need to create a parent div, because there should be one parent element in every React component, and at the top, for now, we will create just a placeholder div with the keyword toolbar inside it (later we might add more). Below that we will create the main element that we have from the Html, here we are going to output the component we wrap this layout, we will use <code>{props.children}</code>. With this, we can use this layout component as a wrapper around the content component. Lastly at the bottom we will export our component. And we got the following code:</p>\n<pre><code class=\"language-JSX\">import React from 'react';\n\nconst layout = (props) => (\n  &#x3C;div>\n    &#x3C;div>Toolbar&#x3C;/div>\n    &#x3C;main>\n      {props.children}\n    &#x3C;/main>\n  &#x3C;/div>\n);\n\nexport default layout;\n</code></pre>\n<p>Now we simply need to use this component in the App.js file. To use it we will import the component at the top, and then simply use it inside the parent div with some test paragraph, as the following example:</p>\n<pre><code class=\"language-JSX\">import React from 'react';\nimport './App.css';\nimport Layout from './components/Layout/Layout'\n\nfunction App() {\n  return (\n    &#x3C;div>\n      &#x3C;Layout>\n        &#x3C;p>Test&#x3C;/p>\n      &#x3C;/Layout>\n    &#x3C;/div>\n  );\n}\n\nexport default App;\n</code></pre>\n<p><ad-incontent></ad-incontent></p>\n<h2>Creating a Cryptocurrencies Container</h2>\n<p>Now let's make our Cryptocurrency component, which will actually be a container because here we will manage the state for the cryptocurrencies. We will create a new folder in the container folder which we will name it CryptoCurrencies, and inside that folder we will make our container component named CryptoCurrencies.js which will be class component becouse it is easier to manage the state. At the end it should look like this:</p>\n<pre><code class=\"language-JSX\">import React, {Component} from 'react';\n\nclass CryptoCurrencies extends Component {\n  render(){\n    return(\n      &#x3C;div>\n        &#x3C;div>Currency1&#x3C;/div>\n        &#x3C;div>Currency2&#x3C;/div>\n        &#x3C;div>Currency3&#x3C;/div>\n      &#x3C;/div>\n    );\n  }\n}\n\nexport default CryptoCurrencies;\n</code></pre>\n<p>This component is a list with Html elements as placeholders for now, but in the future that will change, as we will add components instead of them. Lastly we need to import this component to the App.js like we did with the last one. The App.js final code should look like this:</p>\n<pre><code class=\"language-JSX\">function App() {\n  return (\n    &#x3C;div>\n      &#x3C;Layout>\n        &#x3C;CryptoCurrencies />\n      &#x3C;/Layout>\n    &#x3C;/div>\n  );\n}\n</code></pre>\n<p>And the components tree will look like this:</p>\n<p><img src=\"/assets/samples/create-react-app-from-scratch-components-tree-2.png\" alt=\"component-tree\"></p>\n<p>Now when we go to the <code>localhost:3000</code> we can see our app, with the toolbar placeholder on top and the dummy list after. In later parts, we will apply styling to it and will look much better.</p>\n<p><ad-incontent></ad-incontent></p>\n<h2>Part Overview</h2>\n<p>In this part we have seen, what is a component in React, the difference between class and function components. In the end, we created our first component the layout component which will be our wrapper around the other content, and the CryptoCurrencies component which is a list that will hold the future CryptoCurrency component.</p>\n<p>To learn React much deeper, I recommend you to read this book: </p>\n<p><a href=\"https://www.amazon.com/gp/product/B077HJFCQX/ref=as_li_tl?ie=UTF8&camp=1789&creative=9325&creativeASIN=B077HJFCQX&linkCode=as2&tag=aleksandarvas-20&linkId=6c518448e9ae3041011a1dfc8cea8e00\" style=\"font-weight:bold; text-transform:uppercase; color:#ff7a59;\">The Road to learn React: Your journey to master plain yet pragmatic React.js</a>.</p>\n<p>If you prefer a video course, I highly recommend you to take a look at this course on Udemy:</p>\n<p><a href=\"https://click.linksynergy.com/link?id=LFcSQV4ezac&offerid=507388.1362070&type=2&murl=https%3A%2F%2Fwww.udemy.com%2Fcourse%2Freact-the-complete-guide-incl-redux%2F\"><IMG border=0 src=\"https://i.udemycdn.com/course/480x270/1362070_b9a1_2.jpg\" ><div >React - The Complete Guide (incl Hooks, React Router, Redux)</div></a><IMG border=0 width=1 height=1 src=\"https://ad.linksynergy.com/fs-bin/show?id=LFcSQV4ezac&bids=507388.1362070&type=2&subid=0\" ></p>\n<p>The code from the course is available on GitHub: <a href=\"https://github.com/AleksandarVasilevski/create-react-app-from-scratch\"><strong>Create React App From Scratch</strong></a> on the branch: 02-into-components.</p>\n<p>Next part: <a href=\"https://www.codespot.org/create-react-app-from-scratch-part-3/\" style=\"font-weight:bold; text-transform:uppercase; color:#ff7a59;\">Create React App From Scratch Part 3: Working with Props</a></p>","frontmatter":{"path":"/create-react-app-from-scratch-part-2/","date":"2019-12-18T13:55:49.619Z","title":"Create React App From Scratch Part 2: Into Components","author":"Aleksandar Vasilevski","image":"/assets/cover/create-react-app-from-scratch-part-2.png","category":"React","tags":"#react #js #javascript #createReactAppFromScratch #components","featured":false}}},{"node":{"id":"24ac14db-2851-5f58-8c21-c9a2017ff48a","html":"<p><img src=\"/assets/cover/create-react-app-from-scratch-part-1.png\" alt=\"create-react-app-part-1\"></p>\n<h2>Series Introduction</h2>\n<p>Since React is currently one of the most in-demand front-end technology, I have decided to start a course series that intends to show you how to create the React js app from scratch to finish. Today most of the front-end applications are mostly showing real-time data fetched from some backend service, I have decided that it will be useful to create a cryptocurrency single page application that will show prices and chart history of cryptocurrencies that will be fetched from some backend service.</p>\n<blockquote>\n<p>Note: To follow this ReactJS course series you should have some basic knowledge in JavaScript programming language, even better if you know ES6.</p>\n</blockquote>\n<p><ad-incontent></ad-incontent></p>\n<h2>Setting Up React</h2>\n<p>Before we start setting up the ReactJS app, firstly we need to have node.js installed on our computer. To check if node.js is installed you should open up the terminal or PowerShell in Windows and type:</p>\n<pre><code class=\"language-shell\">node -v\n</code></pre>\n<p>If this shows you the node version, you can skip the installing part, else you should open <a href=\"https://nodejs.org/\"><em>nodejs.org</em></a> and there you will find the latest version of node.js. </p>\n<p>Setting up React js is easy, Firstly we will name the app crypto-app. Next, we will open up the terminal with a path to the folder where we want the app to be stored. To create a React project we need to use the following command:</p>\n<pre><code class=\"language-shell\">npx create-react-app crypto-app\n</code></pre>\n<p>Feel free to name your app differently if you want to, but in my case, I will name the app crypto-app.\nAfter a couple of seconds, the setup will finish with a couple of messages about our new React app. We can now use the following commands when we are inside the directory of the app:</p>\n<pre><code class=\"language-shell\">npm start       #starts the development server\nnpm run build   #bundles the app into static files for production\nnpm test        #starts the test runner\n</code></pre>\n<p>To start our development server, first, we need to go into the project folder with the command <code>cd crypto-app</code>, when we are inside the project folder we can finally start the development server with the command <code>npm start</code>, our browser will open the app for us at localhost:3000, where we should see the React welcome screen.</p>\n<div style=\"display:flex;justify-content:space-evenly;flex-wrap:wrap;\">\n  <iframe style=\"width:120px;height:240px;\" marginwidth=\"0\" marginheight=\"0\" scrolling=\"no\" frameborder=\"0\" src=\"//ws-na.amazon-adsystem.com/widgets/q?ServiceVersion=20070822&OneJS=1&Operation=GetAdHtml&MarketPlace=US&source=ac&ref=tf_til&ad_type=product_link&tracking_id=aleksandarvas-20&marketplace=amazon&region=US&placement=B077HJFCQX&asins=B077HJFCQX&linkId=7d3fc540c6862f4320999c195c561b06&show_border=false&link_opens_in_new_window=false&price_color=333333&title_color=0066c0&bg_color=ffffff\">\n      </iframe>\n  <iframe style=\"width:120px;height:240px;\" marginwidth=\"0\" marginheight=\"0\" scrolling=\"no\" frameborder=\"0\" src=\"//ws-na.amazon-adsystem.com/widgets/q?ServiceVersion=20070822&OneJS=1&Operation=GetAdHtml&MarketPlace=US&source=ac&ref=tf_til&ad_type=product_link&tracking_id=aleksandarvas-20&marketplace=amazon&region=US&placement=1491954620&asins=1491954620&linkId=29e8157ef1033504e1524afcf2d6b579&show_border=false&link_opens_in_new_window=false&price_color=333333&title_color=0066c0&bg_color=ffffff\">\n      </iframe>\n</div>\n<h2>React File Structure</h2>\n<p>To open our React project we need to use a text editor or IDE, if you don't have any installed, you can check my post about <a href=\"https://codespot.org/top-5-best-text-editors-for-2019/\"><em>Top 5 Best Text Editors</em></a>. When we open up the project in the text editor we can see a couple of configuration files and folders.</p>\n<pre><code>- node_modules        - contains all node dependencies\n- public              - public files that are served\n- src                 - source code of our ReactJS app\n.gitignore            - record which files should git ignore\npackage-lock.json     - contains an exact, versioned dependency tree\npackage.json          - contains various metadata relevant to the project \nREADME.md             - readme markdown file\n</code></pre>\n<p>First, we will look into the public folder. Here we have one important file and that is the <code>index.html</code>. This is a normal Html page which is a single page Html, in other words, we are not going to add more Html files to this project.</p>\n<pre><code class=\"language-html\">&#x3C;!DOCTYPE html>\n&#x3C;html lang=\"en\">\n  &#x3C;head>\n    &#x3C;meta charset=\"utf-8\" />\n    &#x3C;link rel=\"icon\" href=\"%PUBLIC_URL%/favicon.ico\" />\n    &#x3C;meta name=\"viewport\" content=\"width=device-width, initial-scale=1\" />\n    &#x3C;meta name=\"theme-color\" content=\"#000000\" />\n    &#x3C;meta\n      name=\"description\"\n      content=\"Web site created using create-react-app\"\n    />\n    &#x3C;link rel=\"apple-touch-icon\" href=\"%PUBLIC_URL%/logo192.png\" />\n    &#x3C;link rel=\"manifest\" href=\"%PUBLIC_URL%/manifest.json\" />\n    &#x3C;title>React App&#x3C;/title>\n  &#x3C;/head>\n  &#x3C;body>\n    &#x3C;noscript>You need to enable JavaScript to run this app.&#x3C;/noscript>\n    &#x3C;div id=\"root\">&#x3C;/div>\n  &#x3C;/body>\n&#x3C;/html>\n</code></pre>\n<blockquote>\n<p>Note: I have deleted the comments so the file will look a bit cleaner, as it is not that complex as it looks like.</p>\n</blockquote>\n<p><ad-incontent></ad-incontent></p>\n<p>If you need to add any inputs, libraries like CSS, or meta tags you can do that here, in this file. Most important part about this file that you should remember is that <code>&#x3C;div id=\"root\">&#x3C;/div></code> is where the React application is mounted.</p>\n<p>Another interesting place for us is the <code>src</code> folder. When we open our <code>src</code> folder we can see a couple of files here, these files are our React application. The most important file here is the <code>index.js</code>. Let's see how does it look:</p>\n<pre><code class=\"language-javascript\">import React from 'react';\nimport ReactDOM from 'react-dom';\nimport './index.css';\nimport App from './App';\nimport * as serviceWorker from './serviceWorker';\n\nReactDOM.render(&#x3C;App />, document.getElementById('root'));\n\n// If you want your app to work offline and load faster, you can change\n// unregister() to register() below. Note this comes with some pitfalls.\n// Learn more about service workers: https://bit.ly/CRA-PWA\nserviceWorker.unregister();\n</code></pre>\n<p>Here the <code>ReactDOM.render(&#x3C;App />, document.getElementById('root'));</code> method renders our React application. As the first argument we have <code>&#x3C;App /></code> component (we will look into React components in depth later, for now, you can think of it like some element) which was imported at the top of our file. The second argument is where we get access to the root element in our DOM, in the Html file, which we saw before in the public folder.</p>\n<p>Now let's open the <code>App.js</code> file, our only ReactJS component for now.</p>\n<pre><code class=\"language-JSX\">import React from 'react';\nimport logo from './logo.svg';\nimport './App.css';\n\nfunction App() {\n  return (\n    &#x3C;div className=\"App\">\n      &#x3C;header className=\"App-header\">\n        &#x3C;img src={logo} className=\"App-logo\" alt=\"logo\" />\n        &#x3C;p>\n          Edit &#x3C;code>src/App.js&#x3C;/code> and save to reload.\n        &#x3C;/p>\n        &#x3C;a\n          className=\"App-link\"\n          href=\"https://reactjs.org\"\n          target=\"_blank\"\n          rel=\"noopener noreferrer\"\n        >\n          Learn React\n        &#x3C;/a>\n      &#x3C;/header>\n    &#x3C;/div>\n  );\n}\n\nexport default App;\n</code></pre>\n<p><ad-incontent></ad-incontent></p>\n<p>Here we see JSX code (we will see later what it is), for now, we will remove all of the content in the wrapping div, also remove the logo import at the top and we will add h1 tag just for testing purpose with text inside it: Hello, World!, and then we will save it!. </p>\n<pre><code class=\"language-JSX\">import React from 'react';\nimport './App.css';\n\nfunction App() {\n  return (\n    &#x3C;div className=\"App\">\n      &#x3C;h1>Hello, World!&#x3C;/h1>\n    &#x3C;/div>\n  );\n}\n\nexport default App;\n</code></pre>\n<p><em>App.js</em></p>\n<p>Because we have <code>npm start</code> command running, this will automatically trigger recompilation, and will also automatically reload your page (localhost:3000), which now you will see: Hello, World, instead of the old content. We can also remove the <code>logo.svg</code> file as we no longer needed. Lastly, let's see the two CSS files available, In the <code>App.css</code> we will delete everything but the first <code>.App</code> class.</p>\n<pre><code class=\"language-css\">.App {\n  text-align: center;\n}\n</code></pre>\n<p><em>App.css</em></p>\n<p>The rest of the files are the <code>serviceWorker.js</code> which is related to the progressive web app, and some files related to unit testing.</p>\n<p><ad-incontent></ad-incontent></p>\n<h2>Part Overview</h2>\n<p>In this part we have seen how we can create React application from scratch, also we have seen the project structure of newly created React application, and at the end, we have tweaked some of the components. </p>\n<p>To learn React much deeper, I recommend you to read this book: </p>\n<p><a href=\"https://www.amazon.com/gp/product/B077HJFCQX/ref=as_li_tl?ie=UTF8&camp=1789&creative=9325&creativeASIN=B077HJFCQX&linkCode=as2&tag=aleksandarvas-20&linkId=6c518448e9ae3041011a1dfc8cea8e00\" style=\"font-weight:bold; text-transform:uppercase; color:#ff7a59;\">The Road to learn React: Your journey to master plain yet pragmatic React.js</a>.</p>\n<p>If you prefer a video course, I highly recommend you to take a look at this course on Udemy:</p>\n<p><a href=\"https://click.linksynergy.com/link?id=LFcSQV4ezac&offerid=507388.1362070&type=2&murl=https%3A%2F%2Fwww.udemy.com%2Fcourse%2Freact-the-complete-guide-incl-redux%2F\"><IMG border=0 src=\"https://i.udemycdn.com/course/480x270/1362070_b9a1_2.jpg\" ><div >React - The Complete Guide (incl Hooks, React Router, Redux)</div></a><IMG border=0 width=1 height=1 src=\"https://ad.linksynergy.com/fs-bin/show?id=LFcSQV4ezac&bids=507388.1362070&type=2&subid=0\" ></p>\n<p>The code from the course is available on GitHub: <a href=\"https://github.com/AleksandarVasilevski/create-react-app-from-scratch\"><strong>Create React App From Scratch</strong></a> on the branch: 01-setting-up.</p>\n<p>Next part: <a href=\"https://www.codespot.org/create-react-app-from-scratch-part-2/\" style=\"font-weight:bold; text-transform:uppercase; color:#ff7a59;\">Create React App From Scratch Part 2: Into Components</a></p>","frontmatter":{"path":"/create-react-app-from-scratch-part-1/","date":"2019-12-16T13:25:49.619Z","title":"Create React App From Scratch Part 1: Setting Up","author":"Aleksandar Vasilevski","image":"/assets/cover/create-react-app-from-scratch-part-1.png","category":"React","tags":"#react #js #javascript #createReactAppFromScratch","featured":false}}},{"node":{"id":"cfa301e1-506d-5ff7-aa12-77b778b7b58f","html":"<p><img src=\"/assets/cover/books-row.jpg\" alt=\"axios-http-client\"></p>\n<p>There are many books out there for programmers and no one can read every book out there. There are many more articles about programming books written too, but it is hard to find a good filtered list with books for programmers. In this article, I wanted to make a list that will help everyone to find particular books about programming topics that they are interested in to read. I selected this particular list of books not just to improve your coding skills and make you a better programmer, but would also help you to grow as a person in every way. </p>\n<p>I have sorted the list by the types of books that I think are the most important. In this list about best books for programmers, you will find books that are foundational to topics in computer science that will introduce you to the major programming concepts, will improve the way you think and your problem-solving ability. You will also find books that will help you write clean code and structure your code greatly. On the list, you will find books that will help you to advance your career as a programmer. And lastly, you will find books that will help you to grow as a person and to achieve the goals you want to achieve in your life. Many of the books listed are also used as textbooks in many computer science and software engineering universities around the world.</p>\n<p><em>There might be affiliate links on this page, which means we get a small commission of anything you buy. As an Amazon Associate we earn from qualifying purchases.</em></p>\n<p><ad-incontent></ad-incontent></p>\n<h2>Foundational Programming Books</h2>\n<p>These programming books are about foundations in programming, some of them are mainly used in universities are textbooks. For people that are coming from other fields into software development, they are highly recommended.</p>\n<div style=\"margin: 40px 0\"></div>\n<img src=\"/assets/books/introduction-to-computing.jpg\" alt=\"introduction-to-computing\" style=\"float:left; width:180px; margin-right: 20px\"/>\n<a href=\"https://www.amazon.com/gp/product/1463687478/ref=as_li_tl?ie=UTF8&camp=1789&creative=9325&creativeASIN=1463687478&linkCode=as2&tag=aleksandarvas-20&linkId=7ca1eddf7349cbaf2b7f29b6b59d885e\" style=\"font-size:25px; color:#ff7a59;\"><h3>Introduction to Computing: Explorations in Language, Logic, and Machines</h3></a>\nThis is a programming book that will introduce you to many concepts in software development and computer science. For the examples, this book uses the Scheme programming language, a functional programming language that is a dialect of Lisp programming language. This book is used in many universities such as MIT as a textbook. If you have a hard time using functional programming you can check the next book.\n<div style=\"margin: 80px 0\"></div>\n<img src=\"/assets/books/explorations-in-computing.jpg\" alt=\"explorations-in-computing\" style=\"float:left; width:180px; margin-right: 20px\"/>\n<a href=\"https://www.amazon.com/gp/product/1466572442/ref=as_li_tl?ie=UTF8&camp=1789&creative=9325&creativeASIN=1466572442&linkCode=as2&tag=aleksandarvas-20&linkId=f44adeaa70da87335b2b783267b59090\" style=\"font-size:25px; color:#ff7a59;\"><h3>Explorations in Computing: An Introduction to Computer Science and Python Programming</h3></a>\nThis book is a great alternative to the Introduction to Computing, as it uses the Python programming language. If you are not with a computer science background, this book is one of the great books to get started. Same as the first one it is used in many universities as a textbook to introduce you to the coding concepts. If you are an absolute beginner this book is highly recommended.\n<div style=\"margin: 80px 0\"></div>\n<img src=\"/assets/books/structure-and-interpretation-of-computer-programs.jpg\" alt=\"structure-and-interpretation-of-computer-programs\" style=\"float:left; width:180px; margin-right: 20px\"/>\n<a href=\"https://www.amazon.com/gp/product/0262510871/ref=as_li_tl?ie=UTF8&camp=1789&creative=9325&creativeASIN=0262510871&linkCode=as2&tag=aleksandarvas-20&linkId=909141111493055bc06f436b176d0f0a\" style=\"font-size:25px; color:#ff7a59;\"><h3>Structure and Interpretation of Computer Programs - 2nd Edition</h3></a>\nIf you have solid foundational in programming you should read this book because this book is a bit challenging, it deals with functional programming and especially if you are coming from other paradigms. This book was written for the introductory programming course at MIT. This book also has great examples that are worth solving, which on the end will make you a much better programmer in the way how you approach and solve problems.\n<div style=\"margin: 80px 0\"></div>\n<img src=\"/assets/books/design-patterns-elements-of-reusable-object-oriented-software.jpg\" alt=\"design-patterns-elements-of-reusable-object-oriented-software\" style=\"float:left; width:180px; margin-right: 20px\"/>\n<a href=\"https://www.amazon.com/gp/product/0201633612/ref=as_li_tl?ie=UTF8&camp=1789&creative=9325&creativeASIN=0201633612&linkCode=as2&tag=aleksandarvas-20&linkId=002b703efa8dbd844a87952b129c430d\" style=\"font-size:25px; color:#ff7a59;\"><h3>Design Patterns: Elements of Reusable Object-Oriented Software</h3></a>\nThis is the most iconic book about the design patterns, it is also well known for its popular name: The Gang of Four. With this book, you will become familiar with the most common design patterns that you will ever use. I consider this book a must-read for every programmer, but as it can be a bit hard for beginners. In the end, this book will make you a much better programmer.\n<div style=\"margin: 80px 0\"></div>\n<img src=\"/assets/books/head-first-design-patterns.jpg\" alt=\"head-first-design-patterns\" style=\"float:left; width:180px; margin-right: 20px\"/>\n<a href=\"https://www.amazon.com/gp/product/0596007124/ref=as_li_tl?ie=UTF8&camp=1789&creative=9325&creativeASIN=0596007124&linkCode=as2&tag=aleksandarvas-20&linkId=0d8127f96f94fc7ea41435040c0f5536\" style=\"font-size:25px; color:#ff7a59;\"><h3>Head First Design Patterns: A Brain-Friendly Guides</h3></a>\nIf you are a beginner and you find the previous book about design patterns a bit hard, this book is for you. With this book, you will much easier understand the design patterns and then go back to the classic one to improve the understanding. Or if you have read just the classic one, this book is still great to renew the understanding.\n<div style=\"margin: 80px 0\"></div>\n<img src=\"/assets/books/clean-code.jpg\" alt=\"clean-code\" style=\"float:left; width:180px; margin-right: 20px\"/>\n<a href=\"https://www.amazon.com/gp/product/0132350882/ref=as_li_tl?ie=UTF8&camp=1789&creative=9325&creativeASIN=0132350882&linkCode=as2&tag=aleksandarvas-20&linkId=997a64b79c9dd207b9e241f8730de132\" style=\"font-size:25px; color:#ff7a59;\"><h3>Clean Code: A Handbook of Agile Software Craftsmanship</h3></a>\nI highly recommend this book, because this programming book is one of the best you will ever read and will completely change the way you write code. Clean Code deals with some of the concepts like naming, functions, formatting, comments, error handling but on a higher level. This is the book that every programmer must have it.\n<div style=\"margin: 80px 0\"></div>\n<img src=\"/assets/books/the-art-of-computer-programming.jpg\" alt=\"the-art-of-computer-programming\" style=\"float:left; width:180px; margin-right: 20px\"/>\n<a href=\"https://www.amazon.com/gp/product/0321751043/ref=as_li_tl?ie=UTF8&camp=1789&creative=9325&creativeASIN=0321751043&linkCode=as2&tag=aleksandarvas-20&linkId=403622fbebefcacbebbfc08a5c2dee2f\" style=\"font-size:25px; color:#ff7a59;\"><h3>The Art of Computer Programming, Volumes 1-4A</h3></a>\nWith its four volumes, The Art of Computer Programming is one of the greatest books about Computer Science ever written. This book is state-of-the-art as Bill Gates once said, “If you think you’re a really good programmer… read Art of Computer Programming… You should definitely send me a resume if you can read the whole thing.” I still have not read this book but it is high on my priority list.\n<div style=\"margin: 80px 0\"></div>\n<p><ad-incontent></ad-incontent></p>\n<h2>Algorithms and Data Structures Programming Books</h2>\n<p>These books for programmers are about improving the way you think and solving-problems, also with these books you will learn how to solve interviews whiteboard questions. Some of these books are also used in universities are textbooks. These books are highly recommended if your goal is to improve logic ability.</p>\n<div style=\"margin: 40px 0\"></div>\n<img src=\"/assets/books/introduction-to-algorithms.jpg\" alt=\"introduction-to-algorithms\" style=\"float:left; width:180px; margin-right: 20px\"/>\n<a href=\"https://www.amazon.com/gp/product/0262033844/ref=as_li_tl?ie=UTF8&camp=1789&creative=9325&creativeASIN=0262033844&linkCode=as2&tag=aleksandarvas-20&linkId=8eb3e29877fdf8b1284a3251ef850a49\" style=\"font-size:25px; color:#ff7a59;\"><h3>Introduction to Algorithms, 3rd Editions</h3></a>\nThis book is considered to be the best book for learning algorithms and data structures. With this book, you will not just learn all of the important algorithms that are asked on interviews but you will also greatly improve the problem-solving ability as a programmer. It is a great book to have it under your belt.\n<div style=\"margin: 80px 0\"></div>\n<img src=\"/assets/books/cracking-the-coding-interview-150-programming-questions-and-solutions.jpg\" alt=\"cracking-the-coding-interview-150-programming-questions-and-solutions\" style=\"float:left; width:180px; margin-right: 20px\"/>\n<a href=\"https://www.amazon.com/gp/product/098478280X/ref=as_li_tl?ie=UTF8&camp=1789&creative=9325&creativeASIN=098478280X&linkCode=as2&tag=aleksandarvas-20&linkId=bd21b206c903b4a3162032b58992eb75\" style=\"font-size:25px; color:#ff7a59;\"><h3>Cracking the Coding Interview: 150 Programming Questions and Solutions</h3></a>\nThis book is one of the top-selling book for programmers on Amazon because it is simply great. In this programming book, you will find great interview pieces of advice that will help you not only to get the job you want but also to make you a better programmer overall. As you read the book do the exercises as well, if you master the exercises it will be hard not to pass a programming interview.\n<div style=\"margin: 80px 0\"></div>\n<p><ad-incontent></ad-incontent></p>\n<h2>Architecture-Based Programming Books</h2>\n<p>Books in this section are great for extending the way on how you think from the bigger picture of problem-solving. Architectural based books make you see from another angle, on how to design the program.</p>\n<div style=\"margin: 40px 0\"></div>\n<img src=\"/assets/books/domain-driven-design.jpg\" alt=\"domain-driven-design\" style=\"float:left; width:180px; margin-right: 20px\"/>\n<a href=\"https://www.amazon.com/gp/product/0321125215/ref=as_li_tl?ie=UTF8&camp=1789&creative=9325&creativeASIN=0321125215&linkCode=as2&tag=aleksandarvas-20&linkId=7b61109d676c9e59d1851246ec1d1891\" style=\"font-size:25px; color:#ff7a59;\"><h3>Domain-Driven Design: Tackling Complexity in the Heart of Software</h3></a>\nWith this book, you will learn how to create maintainable architecture that is based on domain modeling. It is not the easiest book to read but it worth the effort. After you read this book you will think differently about software development architecture. This book is also one of the most recommended books about software architecture.\n<div style=\"margin: 80px 0\"></div>\n<img src=\"/assets/books/patterns-of-enterprise-application-architecture.jpg\" alt=\"patterns-of-enterprise-application-architecture\" style=\"float:left; width:180px; margin-right: 20px\"/>\n<a href=\"https://www.amazon.com/gp/product/0321127420/ref=as_li_tl?ie=UTF8&camp=1789&creative=9325&creativeASIN=0321127420&linkCode=as2&tag=aleksandarvas-20&linkId=4d8bd0e6ebc2889fe637e1b9694eb16d\" style=\"font-size:25px; color:#ff7a59;\"><h3>Patterns of Enterprise Application Architecture</h3></a>\nFor programming any kind of enterprise application this book is one of the top books in software architecture and is extremely useful to read, here you will learn how to analyze, design and build enterprise applications from scratch to production-ready. You will want to have this book in your collection also as a reference every time you design and build an enterprise application. \n<div style=\"margin: 80px 0\"></div>\n<img src=\"/assets/books/refactoring-to-patterns.jpg\" alt=\"refactoring-to-patterns\" style=\"float:left; width:180px; margin-right: 20px\"/>\n<a href=\"https://www.amazon.com/gp/product/0321213351/ref=as_li_tl?ie=UTF8&camp=1789&creative=9325&creativeASIN=0321213351&linkCode=as2&tag=aleksandarvas-20&linkId=d2d0421222531c9b297d781ce75cb846\" style=\"font-size:25px; color:#ff7a59;\"><h3>Refactoring to Patterns</h3></a>\nReading this book is not just a theory about design patterns, but it is focused on implementing them in practice. With this book, you will learn how to practically turn existing code into patterns and even how to move it out of patterns. If you are serious about design patterns it is a must-have book under your belt and into your collection for future reference.\n<div style=\"margin: 140px 0\"></div>\n<p><ad-incontent></ad-incontent></p>\n<h2>Programming Language Related Programming Books</h2>\n<p>Here you will find books about learning programming languages, from the most popular one to the new kids on the block. With these books, you will not only learn another programming language like in youtube videos, but you will extend the way of thinking in a particular programming paradigm.</p>\n<div style=\"margin: 40px 0\"></div>\n<img src=\"/assets/books/javascript-the-good-parts.jpg\" alt=\"javascript-the-good-parts\" style=\"float:left; width:180px; margin-right: 20px\"/>\n<a href=\"https://www.amazon.com/gp/product/0596517742/ref=as_li_tl?ie=UTF8&camp=1789&creative=9325&creativeASIN=0596517742&linkCode=as2&tag=aleksandarvas-20&linkId=aa6e1c54a0079bd07819243b38bc8bea\" style=\"font-size:25px; color:#ff7a59;\"><h3>JavaScript: The Good Parts</h3></a>\nIf I have to choose just one book about JavaScript, that would be JavaScript: The Good Parts. With reading this book you will learn the core of the JavaScript programming language, and it will open you a door to the web development world. Although this book is missing some modern parts of the language it is still worth reading.\n<div style=\"margin: 80px 0\"></div>\n<img src=\"/assets/books/thinking-in-java.jpg\" alt=\"thinking-in-java\" style=\"float:left; width:180px; margin-right: 20px\"/>\n<a href=\"https://www.amazon.com/gp/product/0131872486/ref=as_li_tl?ie=UTF8&camp=1789&creative=9325&creativeASIN=0131872486&linkCode=as2&tag=aleksandarvas-20&linkId=afce6ec7114e77d1819a623fd971e439\" style=\"font-size:25px; color:#ff7a59;\"><h3>Thinking in Java (4th Edition)</h3></a>\nThis is the best book to learn Java programming language, and also maybe the best way to learn the object-oriented paradigm. This was the first book I have read about coding and I am still using this book as a reference about Java. I have written a special [*review*](https://www.codespot.org/review-thinking-in-java/) of this book if you want to learn more feel free to check it. I highly recommend you to get this book.\n<div style=\"margin: 80px 0\"></div>\n<img src=\"/assets/books/effective-modern-c++.jpg\" alt=\"effective-modern-c++\" style=\"float:left; width:180px; margin-right: 20px\"/>\n<a href=\"https://www.amazon.com/gp/product/1491903996/ref=as_li_tl?ie=UTF8&camp=1789&creative=9325&creativeASIN=1491903996&linkCode=as2&tag=aleksandarvas-20&linkId=14f286e45e3af4158bedae82f0f742b5\" style=\"font-size:25px; color:#ff7a59;\"><h3>Effective Modern C++: 42 Specific Ways to Improve Your Use of C++11 and C++14</h3></a>\nOne more book that is focused on heavyweight programming language that ic C++. Effective Modern C++ is one of the best books for anyone who wants to learn C++. By reading this book, will improve you a lot as a programmer as you will learn object-oriented programming paradigm. It is a recommended book by many programmers for entering into the C++ world.\n<div style=\"margin: 80px 0\"></div>\n<img src=\"/assets/books/c-sharp-in-depth.jpg\" alt=\"c-sharp-in-depth\" style=\"float:left; width:180px; margin-right: 20px\"/>\n<a href=\"https://www.amazon.com/gp/product/161729134X/ref=as_li_tl?ie=UTF8&camp=1789&creative=9325&creativeASIN=161729134X&linkCode=as2&tag=aleksandarvas-20&linkId=4b59b7f7ccaca3b05ae93a372c392e93\" style=\"font-size:25px; color:#ff7a59;\"><h3>C# in Depth, 3rd Editions</h3></a>\nThis book about the C# programming language will make you dive deep into learning the language as its name says. It is mostly focused on the language itself instead of teaching you how to build applications. In other words, reading this book you will learn how to use various tools in the toolbox, but will not teach you how to build a house.\n<div style=\"margin: 80px 0\"></div>\n<img src=\"/assets/books/learning-python.jpg\" alt=\"learning-python\" style=\"float:left; width:180px; margin-right: 20px\"/>\n<a href=\"https://www.amazon.com/gp/product/1449355730/ref=as_li_tl?ie=UTF8&camp=1789&creative=9325&creativeASIN=1449355730&linkCode=as2&tag=aleksandarvas-20&linkId=7f71811dcabf6c2b4bb3ead03adc0133\" style=\"font-size:25px; color:#ff7a59;\"><h3>Learning Python: Powerful Object-Oriented Programming</h3></a>\nLearning Python is a book that goes into tiny details about the language. It is a traditional book focused mostly on theory, and not a project-based book. So if you want to learn Python you can't be wrong with this book, it is good for beginners who start coding or even experienced developers who want to jump straight into the language.\n<div style=\"margin: 80px 0\"></div>\n<img src=\"/assets/books/kotlin-in-action.jpg\" alt=\"kotlin-in-action\" style=\"float:left; width:180px; margin-right: 20px\"/>\n<a href=\"https://www.amazon.com/gp/product/1617293296/ref=as_li_tl?ie=UTF8&camp=1789&creative=9325&creativeASIN=1617293296&linkCode=as2&tag=aleksandarvas-20&linkId=123f663df10b61219c39520618b0096a\" style=\"font-size:25px; color:#ff7a59;\"><h3>Kotlin in Actions</h3></a>\nKotlin in Action is one of the best books about this young programming language which steps forward pretty quickly. With the Kotlin introduction to Android by Google a couple of years ago, this book has become most wanted if you plan to learn Kotlin. You will find the book also on the official Kotlin website ranked as the best book to learn the language.\n<div style=\"margin: 80px 0\"></div>\n<img src=\"/assets/books/programming-elixir.jpg\" alt=\"programming-elixir\" style=\"float:left; width:180px; margin-right: 20px\"/>\n<a href=\"https://www.amazon.com/gp/product/1680502999/ref=as_li_tl?ie=UTF8&camp=1789&creative=9325&creativeASIN=1680502999&linkCode=as2&tag=aleksandarvas-20&linkId=8f44df5708dbe873182f8900f9b7b0d8\" style=\"font-size:25px; color:#ff7a59;\"><h3>Programming Elixir: Functional |> Concurrent |> Pragmatic |> Fun</h3></a>\nIf you want to dive into functional programming with Elixir, you are in right place. Reading this book will take you yo another level in the functional world and will shape the way you think and solve problems differently. Also, the Elixir programming language is on great rising trends like Kotlin with high job demand. Simply it is the best book about learning Elixir.\n<div style=\"margin: 80px 0\"></div>\n<img src=\"/assets/books/the-rust-programming-language.jpg\" alt=\"the-rust-programming-language\" style=\"float:left; width:180px; margin-right: 20px\"/>\n<a href=\"https://www.amazon.com/gp/product/1718500440/ref=as_li_tl?ie=UTF8&camp=1789&creative=9325&creativeASIN=1718500440&linkCode=as2&tag=aleksandarvas-20&linkId=2b825cf669235745d42c1adcb99af5ae\" style=\"font-size:25px; color:#ff7a59;\"><h3>The Rust Programming Language</h3></a>\nThis book is the official book on Rust programming language, an open-source, community-developed systems programming language that runs blazingly fast, prevents segfaults, and guarantees thread safety. This book is a go-to guide written by members of the Rust team. This is one more book on rising trends, which worth reading. \n<div style=\"margin: 100px 0\"></div>\n<img src=\"/assets/books/the-c-programming-language.jpg\" alt=\"the-c-programming-language\" style=\"float:left; width:180px; margin-right: 20px\"/>\n<a href=\"https://www.amazon.com/gp/product/0131103628/ref=as_li_tl?ie=UTF8&camp=1789&creative=9325&creativeASIN=0131103628&linkCode=as2&tag=aleksandarvas-20&linkId=20febff4db90f47a9e2dea5b0d449d7e\" style=\"font-size:25px; color:#ff7a59;\"><h3>The C Programming Language</h3></a>\nThis book is something I cannot skip, it is a legendary book about the C programming language, from the same authors which also designed and implemented the C language, as well as co-designing the Unix operating system. This book is regarded by many to be the authoritative reference on C programming language and with it, you will learn the language and also you will see how to program on the lower level which is very important for every programmer. \n<div style=\"margin: 80px 0\"></div>\n<img src=\"/assets/books/the-go-programming-language.jpg\" alt=\"the-go-programming-language\" style=\"float:left; width:180px; margin-right: 20px\"/>\n<a href=\"https://www.amazon.com/gp/product/0134190440/ref=as_li_tl?ie=UTF8&camp=1789&creative=9325&creativeASIN=0134190440&linkCode=as2&tag=aleksandarvas-20&linkId=c956bc708522ca14220e9df3366c088e\" style=\"font-size:25px; color:#ff7a59;\"><h3>The Go Programming Language</h3></a>\nThis book will quickly get you started using Go effectively from the beginning, and by the end, which makes it the best book to learn Go programming language. Golang has become a lot popular lately with the rise of microservices in backend development. The Go programming language was completely designed by Google and it is worth learning it in the long run.\n<div style=\"margin: 80px 0\"></div>\n<p><ad-incontent></ad-incontent></p>\n<h2>Soft Skills and Personal Development Programming Books</h2>\n<p>Lastly but not least important are the books that are targeting the improvement of firstly: the professional development of every programmer and the personal growth in the field of software development, and secondary: the soft skills not just about programmers but these books will help you to be successful in other fields of life.</p>\n<div style=\"margin: 40px 0\"></div>\n<img src=\"/assets/books/the-pragmatic-programmer-from-journeyman-to-master.jpg\" alt=\"the-pragmatic-programmer-from-journeyman-to-master\" style=\"float:left; width:180px; margin-right: 20px\"/>\n<a href=\"https://www.amazon.com/gp/product/020161622X/ref=as_li_tl?ie=UTF8&camp=1789&creative=9325&creativeASIN=020161622X&linkCode=as2&tag=aleksandarvas-20&linkId=66205683ce9e8532c3b03f425d658cc9\" style=\"font-size:25px; color:#ff7a59;\"><h3>The Pragmatic Programmer: From Journeyman to Master</h3></a>\nThis is a book about software engineering where does not present a systematic theory, but rather a collection of tips to improve the development process pragmatically. You will learn things like test, coordinate, release, debug, manage and support. The Pragmatic Programmer is a very influential book in the field of programming and it is used as a textbook in a lot of university courses.\n<div style=\"margin: 80px 0\"></div>\n<img src=\"/assets/books/the-clean-coder.jpg\" alt=\"the-clean-coder\" style=\"float:left; width:180px; margin-right: 20px\"/>\n<a href=\"https://www.amazon.com/gp/product/0137081073/ref=as_li_tl?ie=UTF8&camp=1789&creative=9325&creativeASIN=0137081073&linkCode=as2&tag=aleksandarvas-20&linkId=7c692a451c8841dea71fbbf330655d51\" style=\"font-size:25px; color:#ff7a59;\"><h3>The Clean Coder</h3></a>\nThis book is all about to make you a professional programmer, a lot of the developers will not like this book because it has some tough pieces of advice. But when we see that this book is from a Bob Marting (Uncle Bob) who is a veteran in the software developing industry, it says everything. You will found this book helpful in shaping your professional career and making decisions.\n<div style=\"margin: 80px 0\"></div>\n<img src=\"/assets/books/soft-skills-the-software-developer’s-life-manual.jpg\" alt=\"soft-skills-the-software-developer’s-life-manual\" style=\"float:left; width:180px; margin-right: 20px\"/>\n<a href=\"https://www.amazon.com/gp/product/1617292397/ref=as_li_tl?ie=UTF8&camp=1789&creative=9325&creativeASIN=1617292397&linkCode=as2&tag=aleksandarvas-20&linkId=978cd24250cc48370ce48c71cc977f84\" style=\"font-size:25px; color:#ff7a59;\"><h3>Soft Skills: The software developer's life manual</h3></a>\nOne more interesting book that will boost your soft skills greatly, it is everywhere on every list you will find out. This book will help you to improve from career to personal branding, blogging, learning, teaching, being productive, finances, and even a bit on fitness and relationships. If you lack soft skills and want to learn more about it, you can't be wrong with this book.\n<div style=\"margin: 80px 0\"></div>","frontmatter":{"path":"/best-books-for-programmers/","date":"2019-12-13T22:15:49.619Z","title":"Best Books for Programmers (Updated 2021)","author":"Aleksandar Vasilevski","image":"/assets/cover/books-row.jpg","category":"Books","tags":"#tools #books #book #programming #learning","featured":false}}},{"node":{"id":"50617df7-8eef-52dd-b19a-aec60ee42b40","html":"<p><img src=\"/assets/cover/sql.jpg\" alt=\"cover-photo\"></p>\n<p>To query data from a single table we usually use the select statement in SQL, but sometimes we might want to query data from more than one table. In this article, we will see how we can do that with inner join in SQL, but also we will look at the full join, right join, and left join in SQL to query data from two or more tables.</p>\n<blockquote>\n<p>Note: To query data from a single table we usually use the <strong>SELECT * FROM table_name</strong> statement.</p>\n</blockquote>\n<p><ad-incontent></ad-incontent></p>\n<h2>SQL Inner Join</h2>\n<p>To query data from two or more tables we must use a process that will link both tables together. The process of linking is called joining. SQL provides more than one kind of joins such as inner join, left join, right join, full join, etc, but now we ill focus on inner join in SQL.</p>\n<p>The inner join links two (or more) tables by a relationship between two columns. Whenever you use the inner join clause, you normally think about the intersection between both tables (in case you have two). To understand the concept of inner join in SQL we will look at a simple example:</p>\n<img src=\"/assets/samples/sql-inner-join.png\" alt=\"sql-inner-join\" style=\"margin:auto; display:block\"/>\n<p>Here we have two tables A and B, table A has four rows: 1, 2, 3, 4 and table B has also four rows: 3, 4, 5, 6. When table A joins with table B, we have a result of the intersection of table A and table B which is: 3, 4. The inner join clause finds each row in table A that matches each row in table B, all rows that match are included in the final result.</p>\n<p>We use the following syntax in SQL to inner join table A with table B.</p>\n<pre><code class=\"language-sql\">SELECT A.n FROM A INNER JOIN B ON B.n = A.n;\n</code></pre>\n<p>As we see in the SQL code example above, we are using the INNER JOIN clause after the FROM clause. The condition to match between both tables A and B is specified after the ON keyword. This condition is called join condition, B.n = A.n.</p>\n<p>We can use the INNER JOIN clause to join three or more tables as long as they have relationships between them, typically foreign key relationship is used.</p>\n<pre><code class=\"language-sql\">SELECT A.n FROM A INNER JOIN B ON B.n = A.n INNER JOIN C ON C.n = A.n;\n</code></pre>\n<p>Here we have inner join on three tables.</p>\n<p><ad-incontent></ad-incontent></p>\n<h3>Inner Join in SQL Example Two</h3>\n<p>Let's see one more example of the inner join in SQL. We will use the <code>users</code> and <code>locations</code> table to demonstrates how the inner join in SQL works.</p>\n<img src=\"/assets/samples/users-locations-table.png\" alt=\"sql-users-locations-table\" style=\"margin:auto; display:block\"/>\n<p>Each user belongs to only one location while each location can have more than one user. The relationship between the users and the locations table is one-to-many.\nThe <code>location_id</code> column in the user's table is the foreign key column that links the users to the locations table.</p>\n<p>To get the information of the location id 1 and 2, we use the following statement.</p>\n<pre><code class=\"language-sql\">SELECT location_id, location_name FROM locations WHERE location_id IN (1, 2);\n</code></pre>\n<p>As you can see we are using the IN in the WHERE clause to get the rows with location_id 1 and 2.\nTo get the info of users from the locations with id 1 and 2, we use the following query:</p>\n<pre><code class=\"language-sql\">SELECT first_name, last_name, location_id FROM users WHERE location_id IN (1, 2) ORDER BY location_id;\n</code></pre>\n<p>And if we want to combine data from both tables, we can use an inner join clause like the following query:</p>\n<pre><code class=\"language-sql\">SELECT first_name, last_name, locations.location_name FROM users INNER JOIN locations ON locations.location_id = users.location_id WHERE users.locations_id IN (1, 2);\n</code></pre>\n<p><ad-incontent></ad-incontent></p>\n<h2>SQL Left Join</h2>\n<p>Left join in SQL is useful when we want to link tables together but the result is different from the inner join. Let's look at the example of left join in SQL:</p>\n<img src=\"/assets/samples/sql-left-join.png\" alt=\"sql-left-join\" style=\"margin:auto; display:block\"/>\n<p>Here we also have the same two tables as before, A and B. When table A left joins with table B, we have a result of every row in table A and the matched records from table B, which is: 1, 2, 3, 4. </p>\n<p>The following syntax in SQL is used to left join table A with table B.</p>\n<pre><code class=\"language-sql\">SELECT A.n FROM A LEFT JOIN B ON B.n = A.n;\n</code></pre>\n<p>We have the LEFT JOIN clause after the FROM clause. The condition that is after the ON is called the join condition B.n = A.n.</p>\n<h2>SQL Right Join</h2>\n<p>The right join in SQL is almost the same as the left join with minor differences.</p>\n<img src=\"/assets/samples/sql-right-join.png\" alt=\"sql-right-join\" style=\"margin:auto; display:block\"/>\n<p>We are using the same two tables again, A and B. When table A right joins with table B, we have a result of every row in table B and the matched records from table A, which is: 3, 4, 5, 6. Here the difference from the left join is that we are getting the opposite table. </p>\n<p>The syntax for right join in SQL looks like this.</p>\n<pre><code class=\"language-sql\">SELECT A.n FROM A RIGHT JOIN B ON B.n = A.n;\n</code></pre>\n<p>We have the RIGHT JOIN clause after the FROM clause. The condition that is after the ON is called the join condition B.n = A.n.</p>\n<blockquote>\n<p>Note: In both left join and right join we get the matched records, but the difference is that in left join we have every column from table A, and in right join, we have every column from table B.</p>\n</blockquote>\n<h2>SQL Full Outer Join</h2>\n<p>The full outer join (full join) includes every row from the joined tables whether or not it has the matching rows. If the rows in the joined tables do not match,  the result set of the full join will contain NULL values for every column of the table that doesn't have a matching row. For the matching rows, every single row that has the columns populated from the joined table will be included in the result set.</p>\n<img src=\"/assets/samples/sql-full-join.png\" alt=\"sql-full-join\" style=\"margin:auto; display:block\"/>\n<blockquote>\n<p>Note: Full outer join and outer join in sql are the same.</p>\n</blockquote>\n<p>The syntax for the full outer join looks like this:</p>\n<pre><code class=\"language-sql\">SELECT column_list FROM A FULL OUTER JOIN B ON B.n = A.n;\n</code></pre>\n<p><ad-incontent></ad-incontent></p>\n<p>We have the FULL OUTER JOIN clause after the FROM clause. The condition after the ON is called the join condition B.n = A.n.</p>\n<p>Joining in SQL is very important in many situations when we are working with more than one table, and it is very useful to know about it. If you find this article useful please share it.</p>\n<blockquote>\n<p>Note: If you want to learn more about SQL, I highly recommend you to read this book: <a href=\"https://www.amazon.com/gp/product/0672336073/ref=as_li_tl?ie=UTF8&#x26;camp=1789&#x26;creative=9325&#x26;creativeASIN=0672336073&#x26;linkCode=as2&#x26;tag=aleksandarvas-20&#x26;linkId=19f711b4f4a19a65da0c8e1081adbc6a\"><strong>SQL in 10 Minutes, Sams Teach Yourself (4th Edition)</strong></a>.</p>\n</blockquote>","frontmatter":{"path":"/sql-join/","date":"2019-12-10T14:00:49.619Z","title":"SQL Inner Join, (Left, Right and Full Outer Join)","author":"Aleksandar Vasilevski","image":"/assets/cover/sql.jpg","category":"SQL","tags":"#sql #database #db #join","featured":false}}},{"node":{"id":"14da8eb5-67a2-5fa7-8d75-5dad4120e988","html":"<p><img src=\"/assets/cover/javascript.png\" alt=\"js-logo\"></p>\n<p>The JavaScript destructuring assignment is a more readable compact and expressive syntax that allows us to destructured values from arrays or properties from objects, into different variables. JavaScript destructuring was a new addition to ES6 which took inspiration from languages like Python. Let's see a simple example of JavaScript destructuring:</p>\n<p>Without destructuring assignment, we need to access the items in an array like this:</p>\n<pre><code class=\"language-javascript\">var firstItem = someArray[0];\nvar secondItem = someArray[1];\nvar thirdItem = someArray[2];\n</code></pre>\n<p>With destructuring assignment, it is more concise and readable:</p>\n<pre><code class=\"language-javascript\">var [first, second, third] = someArray;\n</code></pre>\n<p>As we see in our example above, we can use JavaScript destructuring in so many different ways.</p>\n<p><ad-incontent></ad-incontent></p>\n<h2>Object destructuring</h2>\n<p>Let’s see how we can do object destructuring, starting from the beginning. We use an object literal on the left-hand-side of an assignment expression for object destructuring. Let's start with the basic assignment example.</p>\n<h3>Basic assignment</h3>\n<pre><code class=\"language-javascript\">const user = {\n    firstname: 'John',\n    lastname: 'Doe',\n    nickname: 'jDoe'\n};\n\n// Object Destructuring\nconst { firstname, lastname, nickname } = users;\nconsole.log(firstname, lastname, nickname); // John Doe jDoe\n</code></pre>\n<p>We are here using object destructuring syntax to assign values to three variables: <code>firstname</code>, <code>lastname</code> and <code>nickname</code> using the values from their keys on the user object. This is the simplest example of object destructuring. Now let's see more interesting examples of object destructuring.</p>\n<h3>Assignment without declaration</h3>\n<p>We can assign variable value with destructuring without separate from its declaration. </p>\n<pre><code class=\"language-javascript\">let a, b;\n\n({a, b} = {a: 1, b: 2});\n</code></pre>\n<blockquote>\n<p>Note: It is required to have parentheses ( ... ) around the assignment statement when using object literal destructuring assignment without a declaration.</p>\n</blockquote>\n<h3>Assigning to new variable names</h3>\n<p>We can also assign property from unpacked object to a variable with a different name than the object property.</p>\n<pre><code class=\"language-javascript\">let o = {p: 22, q: true};\nlet {p: foo, q: bar} = o;\n \nconsole.log(foo); // 22 \nconsole.log(bar); // true\n</code></pre>\n<p>In the example above, const {p: foo} = o takes from the object o the property named p and assigns it to a variable named foo.</p>\n<h3>Default values</h3>\n<p>We can also set a default value if the unpacked object value is undefined</p>\n<pre><code class=\"language-javascript\">let {a = 10, b = 5} = {a: 3};\n\nconsole.log(a); // 3\nconsole.log(b); // 5\n</code></pre>\n<p><ad-incontent></ad-incontent></p>\n<h3>Assigning to new variables names and providing default values</h3>\n<p>A property can be:</p>\n<ul>\n<li>unpacked from an object and assigned to a different variable.</li>\n<li>assigned a default value if the unpacked value is undefined.</li>\n</ul>\n<pre><code class=\"language-javascript\">const {a: aa = 10, b: bb = 5} = {a: 3};\n\nconsole.log(aa); // 3\nconsole.log(bb); // 5\n</code></pre>\n<h3>Unpacking fields from objects passed as a function parameter</h3>\n<pre><code class=\"language-javascript\">const user = {\n  id: 42,\n  nickName: 'jdoe',\n  fullName: {\n    firstName: 'John',\n    lastName: 'Doe'\n  }\n};\n\nfunction userId({id}) {\n  return id;\n}\n\nfunction whois({displayName, fullName: {firstName: name}}) {\n  return `${displayName} is ${name}`;\n}\n\nconsole.log(userId(user)); // 42\nconsole.log(whois(user));  // \"jdoe is John\"\n</code></pre>\n<p>In this example, we unpack the id, nickName, and firstName from the user object and we simply output them with <code>console.log</code>.</p>\n<h3>Nested object and array destructuring</h3>\n<p>We can also use nested array destructuring where the item must be an array to use a nested destructuring array literal to assign items to local variables.</p>\n<pre><code class=\"language-javascript\">const metadata = {\n  title: 'Scratchpad',\n  translations: [\n    {\n      locale: 'de',\n      localization_tags: [],\n      last_edit: '2014-04-14T08:43:37',\n      url: '/de/docs/Tools/Scratchpad',\n      title: 'JavaScript-Umgebung'\n    }\n  ],\n  url: '/en-US/docs/Tools/Scratchpad'\n};\n\nlet {\n  title: englishTitle, // rename\n  translations: [\n    {\n       title: localeTitle, // rename\n    },\n  ],\n} = metadata;\n\nconsole.log(englishTitle); // \"Scratchpad\"\nconsole.log(localeTitle);  // \"JavaScript-Umgebung\"\n</code></pre>\n<h3>Combined Array and Object Destructuring</h3>\n<p>There are some cases when we are working with a complex array or object structure and we need to assign values from it to variables. In the next example, we will see that it is possible to combine array and objects in destructuring.</p>\n<pre><code class=\"language-javascript\">const props = [\n  { id: 1, name: 'Fizz'},\n  { id: 2, name: 'Buzz'},\n  { id: 3, name: 'FizzBuzz'}\n];\n\nconst [,, { name }] = props;\n\nconsole.log(name); // \"FizzBuzz\"\n</code></pre>\n<p><ad-incontent></ad-incontent></p>\n<h2>Array destructuring</h2>\n<p>Array destructuring is very similar to object destructuring. In array destructuring, we use an array literal on the left-hand-side of an assignment expression. Each variable on the array literal maps to the item at the same index on the destructured array. Here is a basic example.</p>\n<h3>Basic variable assignment</h3>\n<pre><code class=\"language-javascript\">const rgb = ['one', 'two', 'three'];\n\nconst [red, yellow, green] = rgb;\nconsole.log(red); // \"one\"\nconsole.log(yellow); // \"two\"\nconsole.log(green); // \"three\"\n</code></pre>\n<p>Here we have assigned the items in the rgb array to three local variables: red, green and blue using array destructuring. You may notice that every variable is mapped to the item at the same index on the rgb array.</p>\n<h3>Assignment separate from declaration</h3>\n<p>We can assign a variable value via destructuring separate from the variable's declaration.</p>\n<pre><code class=\"language-javascript\">let a, b;\n\n[a, b] = [1, 2];\nconsole.log(a); // 1\nconsole.log(b); // 2\n</code></pre>\n<h3>Default values</h3>\n<p>We can set a default value to a variable. In this case that the value unpacked from the array will be undefined.</p>\n<pre><code class=\"language-javascript\">let a, b;\n\n[a=5, b=7] = [1];\nconsole.log(a); // 1\nconsole.log(b); // 7\n</code></pre>\n<h3>Swapping variables</h3>\n<p>We can swap two variables values in one destructuring expression.\nIf we want to swap variables without a destructuring assignment, swapping two values requires a temporary variable (in low-level languages, the XOR-swap trick).</p>\n<pre><code class=\"language-javascript\">let a = 1;\nlet b = 3;\n\n[a, b] = [b, a];\nconsole.log(a); // 3\nconsole.log(b); // 1\n\nconst arr = [1,2,3];\n[arr[2], arr[1]] = [arr[1], arr[2]];\nconsole.log(arr); // [1,3,2]\n</code></pre>\n<p><ad-incontent></ad-incontent></p>\n<h3>Parsing an array returned from a function</h3>\n<p>As we know it has been possible to return an array from a function, but with destructuring, we can make more concise the array return value. </p>\n<pre><code class=\"language-javascript\">function f() {\n  return [1, 2];\n}\n\nlet a, b; \n[a, b] = f(); \nconsole.log(a); // 1\nconsole.log(b); // 2\n</code></pre>\n<p>In the example above, the f() function returns the values [1, 2] as its output, which can be parsed in one line with JavaScript destructuring.</p>\n<h3>Ignoring some returned values</h3>\n<p>We can ignore or skip return values that we are not interested in.</p>\n<pre><code class=\"language-javascript\">function f() {\n  return [1, 2, 3];\n}\n\nconst [a, , b] = f();\nconsole.log(a); // 1\nconsole.log(b); // 3\n</code></pre>\n<p>It is also possible to ignore all return values:</p>\n<pre><code class=\"language-javascript\">[,,] = f();\n</code></pre>\n<h3>Assigning the rest of an array to a variable</h3>\n<p>When we destructuring an array, we can unpack and assign the parts of it to a variable using the rest:</p>\n<pre><code class=\"language-javascript\">const [a, ...b] = [1, 2, 3];\nconsole.log(a); // 1\nconsole.log(b); // [2, 3]\n</code></pre>\n<blockquote>\n<p>Note: If a trailing comma is used on the left-hand side with a rest element a SyntaxError will be thrown.</p>\n</blockquote>\n<h3>Nested Array Destructuring</h3>\n<p>We can also do nested destructuring with arrays.</p>\n<pre><code class=\"language-javascript\">const color = ['#FF00FF', [255, 0, 255], 'rgb(255, 0, 255)'];\n\n// Use nested destructuring to assign red, green and blue\nconst [hex, [red, green, blue]] = color;\n\nconsole.log(hex, red, green, blue); // #FF00FF 255 0 255\n</code></pre>\n<p><ad-incontent></ad-incontent></p>\n<p>As we can see in this article ES6 destructuring is useful in many cases. I hope you can understand how the destructuring in JavaScript works if you find this article useful please share it.</p>","frontmatter":{"path":"/javascript-destructuring/","date":"2019-12-06T16:30:49.619Z","title":"Guide to Javascript Destructuring in ES6","author":"Aleksandar Vasilevski","image":"/assets/cover/javascript.png","category":"JavaScript","tags":"#javascript #es6","featured":false}}},{"node":{"id":"36d1c916-7a7a-5d63-8501-bfad51cd4c0f","html":"<p><img src=\"/assets/cover/problem-solving.jpg\" alt=\"rubik-cube\"></p>\n<p>A problem is an obstacle to overcome, once the obstacle circumvented, the problem is solved and we can move on the next one. When we write programs to solve problems, though, we have a larger goal. We don't want to solve just one instance of a particular problem, we want an algorithm that will solve all instances of a problem. A problem is defined by its inputs and the desired output.</p>\n<img src=\"/assets/samples/input-output.png\" style=\"display:block; margin:auto;\" alt=\"input-output\"/>\n<p>Our goal for solving the problem is to devise a procedure that takes inputs that define a problem instance and produces an output that is the solution to that problem. Most problem solving involves breaking problems into simpler and simpler problems until you find problems simple enough that you already know\nhow to solve. This approach of solving problems by breaking them into simpler parts is known as <strong>divide-and-conquer</strong>.</p>\n<blockquote>\n<p>Note: An algorithm is a well-defined, computer-implementable instructions, typically to solve a problem or to perform a computation.</p>\n</blockquote>\n<p><ad-incontent></ad-incontent></p>\n<h2>Recursive Problem Solving</h2>\n<p><img src=\"/assets/samples/recursion.jpg\" alt=\"recursion\">\nRecursive problem solving is where a function calls itself again to repeat the code with a goal to reduce the problem to be simple enough. To define recursion, we use an if expression to test the input. If it is true, the consequent expression is the known answer, otherwise, if the test is false, the recursive case applies the procedure again but with a smaller input. For the application to make progress towards reaching the base case, means the input has to change that gets closer to the base case input. The recursion is more used in functional programming.</p>\n<h3>Recursive Factorial Example</h3>\n<pre><code class=\"language-javascript\">function factorial(number) {\n    if (number === 1) {\n        return 1;\n    }\n    return number * factorial(number - 1);\n}\n</code></pre>\n<p>As we see in the factorial function we have a number parameter which we test with an if statement. If the test is true (the number is <code>1</code>) we stop the cycle, if the test is false (the number is not <code>1</code>) we are multiplying the number with the factorial function, which is called by itself.</p>\n<blockquote>\n<p>Note: Factorial is the operation of multiplying any natural number with all the natural numbers that are smaller than it.</p>\n</blockquote>\n<h3>Recursive Fibonacci Example</h3>\n<pre><code class=\"language-javascript\">function fibonacci(number) {\n    if(number &#x3C;= 1){\n        return 1;\n    }else {\n        return fibonacci(number - 1) + fibonacci(number - 2);\n    }\n}\n</code></pre>\n<p>In our second example is probably one of the most famous algorithms ever <strong>Fibonacci sequence</strong>. We have a number parameter that we test with an if statement. If it is true, then we return 1 and the cycle ends here. if the test is false we are are going on the next test. Here at the else clause, we have a return statement with two Fibonacci functions which are added with the first one have a parameter <code>number - 1</code>  and the second one <code>number - 2</code>.</p>\n<blockquote>\n<p>Note: Fibonacci numbers, also called the Fibonacci sequence, such that each number is the sum of the two preceding ones, starting from 0 and 1.</p>\n</blockquote>\n<p><ad-incontent></ad-incontent></p>\n<h2>Iterative Problem Solving</h2>\n<p><img src=\"/assets/samples/iteration.jpg\" alt=\"recursion\">\nIterative problem solving is based on gradual improvements that loop to repeat some part of the code. To define iteration we use a loop that has a variable that tests the input. If it is true, the loop ends and the answer is known. If the test is false, the loop repeats again and re-evaluate the body expressions of the passed values. For the application to make progress towards reaching the goal, means that the variable that is tested has to change and gets closer to the input. The iteration is more used in imperative programming.</p>\n<h3>Iterative Factorial Example</h3>\n<pre><code class=\"language-javascript\">function factorial(number){\n  var result = 1;\n\n  for(var i = 1; i &#x3C;= number; i++){\n    result = result * i;\n  }\n  return result;\n}\n</code></pre>\n<p>We can see in the iterative factorial example that we have a number parameter in the factorial function which is not tested with if statement like in the recursive problem solving, but with a control variable value (<code>var i</code>). If our test is false (<code>var i</code> is smaller or equal with the <code>number</code>) we simply multiply the <code>result</code> with the <code>i</code> and update the <code>result</code> variable. When the test is true (<code>var i</code> is smaller or equal with the <code>number</code>), the for-loop ends and we return the result.</p>\n<h3>Iterative Fibonacci Example</h3>\n<pre><code class=\"language-javascript\">function fibonacci(number){\n  var a = 1;\n  var b = 0;\n  var temp;\n\n  while (number >= 0){\n    temp = a;\n    a = a + b;\n    b = temp;\n    number--;\n  }\n\n  return b;\n}\n</code></pre>\n<p>In the second example, we have again Fibonacci sequence but with an iterative way. We have a number parameter and three variables on top. In the while loop again we are doing the testing with a control variable, where we check if it is true (<code>number</code> is greater or equal to <code>0</code>) then we continue with the loop. Inside the while-loop body we update the <code>temp</code> variable with the value of <code>a</code>, which after we add <code>a</code> and <code>b</code> and update the <code>a</code> variable with the result, and on the next line we simply update the <code>b</code> variable with the value from <code>temp</code> which was taken from the <code>a</code> variable on the first step. On the last line, we are doing decrement to the <code>number</code> which will be tested again. If the test is false(<code>number</code> is not greater or equal to <code>0</code>) we simply return the <code>b</code> variable.</p>\n<blockquote>\n<p>Note: If you want to learn more about algorithms, I highly recommend you to read this book: <a href=\"https://www.amazon.com/gp/product/0262033844/ref=as_li_tl?ie=UTF8&#x26;camp=1789&#x26;creative=9325&#x26;creativeASIN=0262033844&#x26;linkCode=as2&#x26;tag=aleksandarvas-20&#x26;linkId=b1448a09e1dae8d52f37f6284b923b29\"><strong>Introduction to Algorithms, 3rd Edition (The MIT Press)</strong></a>.</p>\n</blockquote>\n<h2>Conclusion</h2>\n<p>The concepts behind the recursion and iteration is to execute a set of instructions (algorithm) repeatedly. The difference between recursion and iteration is that recursion is simply a function call in which the function is being called by itself until a certain condition is met, while iteration is when a loop is repeatedly executed until a certain condition is met. Both recursion and iteration depend on a condition to know when to stop.</p>\n<p><ad-incontent></ad-incontent></p>\n<p><strong>Key differences to remember between recursion and iteration:</strong></p>\n  <li>In recursion a conditional statement decides the termination of the process, while at iteration control variable value decide the termination.</li>\n  <li>Infinite recursion can lead to out of memomry system crash whereas, infinite iteration consumes CPU cycles.</li>\n  <li>Recursion can be more expensive than iteration in both processor time and memory space.</li>\n  <li>Recursion makes code smaller while iteration makes it longer.</li>\n  <li>Recursion is more towards functional programming, where iteration is more towards imperative programming.</li>\n<p>I hope you can understand how the recursion and iteration work if you find this article helpful please share it.</p>","frontmatter":{"path":"/javascript-solving-problems-recursive-iterative/","date":"2019-12-03T17:40:49.619Z","title":"Solving Problems in JavaScript: Recursive vs Iterative","author":"Aleksandar Vasilevski","image":"/assets/cover/problem-solving.jpg","category":"JavaScript","tags":"#javascript #algorithms #recursion #iteration","featured":false}}},{"node":{"id":"092204d1-8821-57f4-9335-28e146760afe","html":"<p><img src=\"/assets/cover/es2019.png\" alt=\"css-logo\"></p>\n<h2>Overview of Option Catch Binding</h2>\n<p>The optional catch binding is a new feature in JavaScript that was added in the ES10/2019, this feature is useful in some cases when you don't need the binding parameter in the catch clause.</p>\n<p><ad-incontent></ad-incontent></p>\n<pre><code class=\"language-javascript\">try {\n    // do something\n} catch (error) {\n    // we have error parameter to handle it\n}\n</code></pre>\n<p><em>Without optional catch binding</em></p>\n<pre><code class=\"language-javascript\">try {\n    // do something\n} catch {\n    // no binding or parameter to handle it\n}\n</code></pre>\n<p><em>With optional catch binding ES10/2019</em></p>\n<p><ad-incontent></ad-incontent></p>\n<p>As we see our examples above, in the first example you have an error parameter which was not optional before ES2019/10, wherein the second example as you can see the error parameter is not there, because it is optional in the ES2019/10. In the past it was always needed to have the parameter whatever you use it or not, this feature is very useful if you never use the variable error as you don't need for the exception object in the code that handles the exception.</p>\n<blockquote>\n<p>Note: If you are new to JavaScript you can go on the following link to learn more about the <a href=\"https://www.codespot.org/javascript-try-catch-finally/\"><strong>try-catch-finally</strong></a></p>\n</blockquote>\n<h2>Browser Support</h2>\n<table>\n<thead>\n<tr>\n<th>Chrome</th>\n<th>Firefox</th>\n<th>Safari</th>\n<th>IE/Edge</th>\n<th>Node</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<td>66+</td>\n<td>58+</td>\n<td>?</td>\n<td>?</td>\n<td>8+</td>\n</tr>\n</tbody>\n</table>\n<p>I hope you understand how the optional catch binding works in JavaScript if you find this article useful please share it.</p>","frontmatter":{"path":"/javascript-es2019-optional-catch-binding/","date":"2019-12-02T21:30:49.619Z","title":"Optional Catch Binding in JavaScript ES10","author":"Aleksandar Vasilevski","image":"/assets/cover/es2019.png","category":"JavaScript","tags":"#javascript #es2019","featured":false}}},{"node":{"id":"19fdb961-c297-5e39-95d9-20d2bd65d70d","html":"<p><img src=\"/assets/books-2158737_1280.jpg\" alt=\"cover-photo\"></p>\n<p><em>There might be affiliate links on this page, which means we get a small commission of anything you buy. As an Amazon Associate we earn from qualifying purchases.</em></p>\n<p>There are a lot of great learning materials out there. This article is aimed to help developers in the search to find the best learning materials and resources to make everyday developing experience better. 33 learning materials are listed below.</p>\n<p><ad-incontent></ad-incontent></p>\n<h2>1. Clean Code</h2>\n<img src=\"/assets/books/clean-code.jpg\" style=\"height:250px;\" alt=\"clean-code\"/>\n<p>Clean Code by Robert C. Martin (Uncle Bob) is one of the best books for software developers, it is a must-read book. Clean Code like its name says it is focused on how to write clean and good code it is focused on important things in software development like naming, functions, formatting, comments and error handling. It is an evergreen book and every programmer must have it.</p>\n<ul>\n<li><a href=\"https://www.amazon.com/gp/product/0132350882/ref=as_li_tl?ie=UTF8&#x26;camp=1789&#x26;creative=9325&#x26;creativeASIN=0132350882&#x26;linkCode=as2&#x26;tag=aleksandarvas-20&#x26;linkId=b6fe81cadea869d0f0e37095833ea49a\"><strong>Clean Code</strong></a></li>\n</ul>\n<br>\n<h2>2. Introduction to Algorithms</h2>\n<img src=\"/assets/books/introduction-to-algorithms.jpg\" style=\"height:250px;\" alt=\"introduction-to-algorithms\"/>\n<p>Introduction to Algorithms, 3rd Edition by Thomas H. Cormen, Charles E. Leiserson, Ronald L. Rivest, and Clifford Stein, is another great book, this book has been widely used as the textbook for algorithms courses at many universities. For software and web developers without Computer Science degree learning algorithms can be one of the most beneficial topics in solving problems, even if you have a CS degree it is a great book to have it under your belt. </p>\n<ul>\n<li><a href=\"https://www.amazon.com/gp/product/0262033844/ref=as_li_tl?ie=UTF8&#x26;camp=1789&#x26;creative=9325&#x26;creativeASIN=0262033844&#x26;linkCode=as2&#x26;tag=aleksandarvas-20&#x26;linkId=51bc8b73731e331acbe2d29eb54402d0\"><strong>Introduction to Algorithms</strong></a></li>\n</ul>\n<br>\n<h2>3. The Art of Computer Programming</h2>\n<img src=\"/assets/books/the-art-of-computer-programming.jpg\" style=\"height:250px;\" alt=\"the-art-of-computer-programming\"/>\n<p>The Art of Computer Programming by Donald Knuth with its four volumes is one of the greatest books about Computer Science ever written. Bill Gates once said, “If you think you’re a really good programmer… read Art of Computer Programming… You should definitely send me a resume if you can read the whole thing.” I still have not read this book but it is high on my priority list.</p>\n<ul>\n<li><a href=\"https://www.amazon.com/gp/product/0321751043/ref=as_li_tl?ie=UTF8&#x26;camp=1789&#x26;creative=9325&#x26;creativeASIN=0321751043&#x26;linkCode=as2&#x26;tag=aleksandarvas-20&#x26;linkId=54b89e8504e161deeb4088fd0fcfbbf6\"><strong>The Art of Computer Programming</strong></a></li>\n</ul>\n<br>\n<h2>4. HackerRank</h2>\n<p><img src=\"https://www.hackerrank.com/wp-content/uploads/2019/07/hackerrank_share-image_0_default_20190722.png\" alt=\"hacker-rank\"></p>\n<p>HackerRank is a website that is focused on learning and competitive programming challenges that can be solved in a variety of programming languages (including Java, C++, PHP, Python, SQL, JavaScript, etc). HackerRank offers programmers to submits a solution to a programming challenge, their submission is given a score on the accuracy of their output. Programmers are then ranked on the HackerRank leaderboard and earn badges based on their results to drive competition among coders. HackerRank is free for coders to use.</p>\n<ul>\n<li><a href=\"https://www.hackerrank.com/\"><strong>https://www.hackerrank.com/</strong></a></li>\n</ul>\n<br>\n<h2>5. Design Patterns: Elements of Reusable Object-Oriented Software</h2>\n<img src=\"/assets/books/design-patterns-elements-of-reusable-object-oriented-software.jpg\" style=\"height:250px;\" alt=\"design-patterns-elements-of-reusable-object-oriented-software\"/>\n<p>Design Patterns: Elements of Reusable Object-Oriented Software by Erich Gamma, Richard Helm, Ralph Johnson, and John Vlissides, also known as The Gang of Four is one of the greatest books about object-oriented design theory and practice with a very high influence in the field of software development. The book is divided into two parts in the first part it is exploring the capabilities and pitfalls of object-oriented programming and in the second part describing 23 classic software design patterns. The Gang of Four is a must-read book, especially for Object-Oriented Programming.</p>\n<ul>\n<li><a href=\"https://www.amazon.com/gp/product/0201633612/ref=as_li_tl?ie=UTF8&#x26;camp=1789&#x26;creative=9325&#x26;creativeASIN=0201633612&#x26;linkCode=as2&#x26;tag=aleksandarvas-20&#x26;linkId=1c5a459384a38925d285cc9e0715eafa\"><strong>Design Patterns: Elements of Reusable Object-Oriented Software</strong></a></li>\n</ul>\n<br>\n<p><ad-incontent></ad-incontent></p>\n<h2>6. Traversy Media</h2>\n<p><img src=\"/assets/other/traversy-media.jpg\" alt=\"traversy-media\"></p>\n<p>Traversy Media by Brad Traversy is a YouTube channel mostly focused on web development. The Video courses are great, very good and professionally explained and in-deep, the courses are especially good for beginners. The video course materials by Traversy Media are mostly free.</p>\n<ul>\n<li><a href=\"https://www.youtube.com/user/TechGuyWeb\"><strong>Traversy Media YouTube</strong></a></li>\n</ul>\n<br>\n<h2>7. Academind</h2>\n<p><img src=\"/assets/other/academind.jpg\" alt=\"academind\"></p>\n<p>Another great YouTube channel for learning web development is Academind. There are a lot of available tutorials and courses that are very good explained. Some of the tutorials are free on the YouTube channel and some of them you can find it on Udemy.</p>\n<ul>\n<li><a href=\"https://www.youtube.com/channel/UCSJbGtTlrDami-tDGPUV9-w/featured\"><strong>Academind YouTube</strong></a></li>\n</ul>\n<br>\n<h2>8. The C Programming Language</h2>\n<img src=\"/assets/books/the-c-programming-language.jpg\" style=\"height:250px;\" alt=\"the-c-programming-language\"/>\n<p>The C Programming Language by Brian Kernighan and Dennis Ritchie sometimes termed K&#x26;R, after its authors' initials, which also designed and implemented the C language, as well as co-designing the Unix operating system. This book is regarded by many to be the authoritative reference on C programming language and with it, you will learn C programming language and also you will see how to program on the lower level which is very important for every software developer. </p>\n<ul>\n<li><a href=\"https://www.amazon.com/gp/product/0131103628/ref=as_li_tl?ie=UTF8&#x26;camp=1789&#x26;creative=9325&#x26;creativeASIN=0131103628&#x26;linkCode=as2&#x26;tag=aleksandarvas-20&#x26;linkId=2fcbd8635e8352a0bf58e63708c125dc\"><strong>The C Programming Language</strong></a></li>\n</ul>\n<br>\n<h2>9. FreeCodeCamp</h2>\n<p><img src=\"/assets/other/freecodecamp.jpg\" alt=\"freecodecamp\"></p>\n<p>FreeCodeCamp is a learning web platform and online community that focuses to make learning web development accessible to anyone. It has tutorials from HTML, CSS to JavaScript where students progress to project assignments that they must complete either alone or in pairs. There is also a Free Code Camp YouTube channel which is also free like the whole platform.</p>\n<ul>\n<li><a href=\"https://www.freecodecamp.org/\"><strong>https://www.freecodecamp.org/</strong></a></li>\n</ul>\n<br>\n<h2>10. Udacity</h2>\n<p><img src=\"/assets/other/udacity.jpg\" alt=\"freecodecamp\"></p>\n<p>Udacity is another learning platform but it offers courses from web development, android development to machine learning. The video courses are great very good explained, especially the part with the android development I have done them when I started learning software development and they are great you cannot find better video lectures on how to learn android and they are also supported by Google. Udacity has a nanodegree that is paid but most of the lectures you can get it for free too.</p>\n<ul>\n<li><a href=\"https://www.udacity.com/\"><strong>https://www.udacity.com/</strong></a></li>\n</ul>\n<br>\n<p><ad-incontent></ad-incontent></p>\n<h2>11. Thinking in Java</h2>\n<img src=\"/assets/books/thinking-in-java.jpg\" style=\"height:250px;\" alt=\"thinking-in-java\"/>\n<p>Thinking in Java by Bruce Eckel is one of the best books to get into Object-Oriented Programming and you will learn the Java programming language too. Object-Oriented Programming is still one of the most important topics that every programmer should know about. I have written a special <a href=\"https://www.codespot.org/review-thinking-in-java/\"><em>review</em></a> for this book if you want to learn more.</p>\n<ul>\n<li><a href=\"https://www.amazon.com/gp/product/0131872486/ref=as_li_tl?ie=UTF8&#x26;camp=1789&#x26;creative=9325&#x26;creativeASIN=0131872486&#x26;linkCode=as2&#x26;tag=aleksandarvas-20&#x26;linkId=190fdd5b63a5645e7ebaaff74dad2d70\"><strong>Thinking in Java</strong></a></li>\n</ul>\n<br>\n<h2>12. You Don't Know Js</h2>\n<img src=\"/assets/books/you-don't-know-js.jpg\" style=\"height:250px;\" alt=\"you-don't-know-js\"/>\n<p>You Don't Know Js by Kyle Simpson is not just one book, there are five books and they are one of the best way to learn JavaScript, you will read o topics like Scope, Closures, Objects, Classes, Types, Grammar, Sync, Async, ES6 and beyond. You can find all of the books on the links below on Amazon for how it is recommended to start reading them.</p>\n<ul>\n<li><a href=\"https://www.amazon.com/gp/product/B00IV3J2A2/ref=as_li_tl?ie=UTF8&#x26;camp=1789&#x26;creative=9325&#x26;creativeASIN=B00IV3J2A2&#x26;linkCode=as2&#x26;tag=aleksandarvas-20&#x26;linkId=e5cfa89126b44c5a356ba5232000c442\"><strong>You Don't Know JS: Scope &#x26; Closures</strong></a></li>\n<li><a href=\"https://www.amazon.com/gp/product/1491904151/ref=as_li_tl?ie=UTF8&#x26;camp=1789&#x26;creative=9325&#x26;creativeASIN=1491904151&#x26;linkCode=as2&#x26;tag=aleksandarvas-20&#x26;linkId=99632a8bf5cb5c2be14341c4d76cef7f\"><strong>You Don't Know JS: this &#x26; Object Prototypes</strong></a></li>\n<li><a href=\"https://www.amazon.com/gp/product/1491904194/ref=as_li_tl?ie=UTF8&#x26;camp=1789&#x26;creative=9325&#x26;creativeASIN=1491904194&#x26;linkCode=as2&#x26;tag=aleksandarvas-20&#x26;linkId=6ae3820c9cc6bc9aa5cc1dd5d37a93e2\"><strong>You Don't Know JS: Types &#x26; Grammar</strong></a></li>\n<li><a href=\"https://www.amazon.com/gp/product/1491904224/ref=as_li_tl?ie=UTF8&#x26;camp=1789&#x26;creative=9325&#x26;creativeASIN=1491904224&#x26;linkCode=as2&#x26;tag=aleksandarvas-20&#x26;linkId=2194ee8859f26802aea66288ce260ee5\"><strong>You Don't Know JS: Async &#x26; Performance</strong></a></li>\n<li><a href=\"https://www.amazon.com/gp/product/1491904240/ref=as_li_tl?ie=UTF8&#x26;camp=1789&#x26;creative=9325&#x26;creativeASIN=1491904240&#x26;linkCode=as2&#x26;tag=aleksandarvas-20&#x26;linkId=acf6687c3429e8380385f3112f1cb6ba\"><strong>You Don't Know JS: ES6 &#x26; Beyond</strong></a></li>\n</ul>\n<br>\n<h2>13. CSS Tricks</h2>\n<p><img src=\"/assets/other/css-tricks.jpg\" alt=\"css-tricks\"></p>\n<p>CSS-Tricks is a blog where you can find great learning materials about front-end development and especially CSS. The posts are very good explained with examples of code snippets. It is one of the top blogs out there.</p>\n<ul>\n<li><a href=\"https://css-tricks.com/\"><strong>https://css-tricks.com/</strong></a></li>\n</ul>\n<br>\n<h2>14. MIT OpenCourseWare</h2>\n<p><img src=\"https://upload.wikimedia.org/wikipedia/commons/c/c9/Ocwhp.png\" alt=\"mit-open-course-ware\"></p>\n<p>MIT OpenCourseWare (OCW) is one of the best courses for learning software development out there, they are great especially if you don't have a Computer Science degree. There are video courses from Introduction to Computer Science and Programming, Introduction to Algorithms, etc. The best think about MIT OCW is that it is free and available for everyone.</p>\n<ul>\n<li><a href=\"https://www.youtube.com/channel/UCEBb1b_L6zDS3xTUrIALZOw\"><strong>MIT OpenCourseWare YouTube</strong></a></li>\n</ul>\n<br>\n<h2>15. Syntax.FM</h2>\n<p><img src=\"/assets/other/syntax-fm.jpg\" alt=\"syntax-fm\"></p>\n<p>Syntax.FM is a podcast for web developers hosted by Wes Bos and Scott Tolinski, here you can find great episodes that will make you a better programmer. You can listen to it on iTunes, Overcast, Google Podcast, etc, and you will find all of the episodes on the Syntax FM website.</p>\n<ul>\n<li><a href=\"https://syntax.fm/\"><strong>https://syntax.fm/</strong></a></li>\n</ul>\n<br>\n<p><ad-incontent></ad-incontent></p>\n<h2>16. The Pragmatic Programmer: From Journeyman to Master</h2>\n<img src=\"/assets/books/the-pragmatic-programmer-from-journeyman-to-master.jpg\" style=\"height:250px;\" alt=\"the-pragmatic-programmer-from-journeyman-to-master\"/>\n<p>The Pragmatic Programmer: From Journeyman to Master by Andrew Hunt and David Thomas is a book about software engineering where does not present a systematic theory, but rather a collection of tips to improve the development process pragmatically. The Pragmatic Programmer is a very influential book in the field of programming and it is used as a textbook in a lot of university courses.</p>\n<ul>\n<li><a href=\"https://www.amazon.com/gp/product/020161622X/ref=as_li_tl?ie=UTF8&#x26;camp=1789&#x26;creative=9325&#x26;creativeASIN=020161622X&#x26;linkCode=as2&#x26;tag=aleksandarvas-20&#x26;linkId=8ce43f87f57eb3e3b7d223662b25978b\"><strong>The Pragmatic Programmer: From Journeyman to Master</strong></a></li>\n</ul>\n<br>\n<h2>17. Cracking the Coding Interview: 150 Programming Questions and Solutions</h2>\n<img src=\"/assets/books/cracking-the-coding-interview-150-programming-questions-and-solutions.jpg\" style=\"height:250px;\" alt=\"cracking-the-coding-interview-150-programming-questions-and-solutions\"/>\n<p>Cracking the Coding Interview by Gayle Laakmann McDowell gives you the interview preparation that you will need it to get the best software developer jobs. This is a deeply technical book and focuses on the software engineering skills to ace your interview.</p>\n<ul>\n<li><a href=\"https://www.amazon.com/gp/product/098478280X/ref=as_li_tl?ie=UTF8&#x26;camp=1789&#x26;creative=9325&#x26;creativeASIN=098478280X&#x26;linkCode=as2&#x26;tag=aleksandarvas-20&#x26;linkId=2fac0228035394b6d883310b820709b7\"><strong>Cracking the Coding Interview: 150 Programming Questions and Solutions</strong></a></li>\n</ul>\n<br>\n<h2>18. DerekBanas</h2>\n<p><img src=\"/assets/other/derek-banas.jpg\" alt=\"derek-banas\"></p>\n<p>Another great YouTube channel by Darek Banas, that is producing very good videos to learn to code, although it is a bit fast-paced for my taste if you like fast-paced videos it can be very useful for you.</p>\n<ul>\n<li><a href=\"https://www.youtube.com/user/derekbanas/featured\"><strong>DerekBanas YouTube</strong></a></li>\n</ul>\n<br>\n<h2>19. TheNewBoston</h2>\n<p><img src=\"/assets/other/the-new-boston.jpg\" alt=\"the-new-boston\"></p>\n<p>The New Boston Youtube channel is one of my favorites for beginner learning materials, although it is not updated a couple of years it still offers great video courses that can help a lot of entry-level programmers.</p>\n<ul>\n<li><a href=\"https://www.youtube.com/user/thenewboston/feature\"><strong>TheNewBoston YouTube</strong></a></li>\n</ul>\n<br>\n<h2>20. Head First Design Patterns</h2>\n<img src=\"/assets/books/head-first-design-patterns.jpg\" style=\"height:250px;\" alt=\"head-first-design-patterns\"/>\n<p>Head First Design Patterns by Eric Freeman, Kathy Sierra, Bert Bates, Elisabeth Robson is another book about design patterns in programming, reading this book will make design patterns much easier to understand. Head First book series is written especially yo target entry-level programmers.</p>\n<ul>\n<li><a href=\"https://www.amazon.com/gp/product/0596007124/ref=as_li_tl?ie=UTF8&#x26;camp=1789&#x26;creative=9325&#x26;creativeASIN=0596007124&#x26;linkCode=as2&#x26;tag=aleksandarvas-20&#x26;linkId=84a59cbd68cd108928e7792513b1d57f\"><strong>Head First Design Patterns</strong></a></li>\n</ul>\n<br>\n<p><ad-incontent></ad-incontent></p>\n<h2>21. JavaScript: the Good Parts</h2>\n<img src=\"/assets/books/javascript-the-good-parts.jpg\" style=\"height:250px;\" alt=\"javascript-the-good-parts\"/>\n<p>Another great JavaScript book the JavaScript: The Good Parts by Douglas Crockford is essential if you want to learn JavaScript programming language If I rank this book I will say You Don't Know Js is a bit better because the JavaScript evolves very fast and You Don't Know Js is more updated.</p>\n<ul>\n<li><a href=\"https://www.amazon.com/gp/product/0596517742/ref=as_li_tl?ie=UTF8&#x26;camp=1789&#x26;creative=9325&#x26;creativeASIN=0596517742&#x26;linkCode=as2&#x26;tag=aleksandarvas-20&#x26;linkId=731d01fa669fa81d1ca273ceaa632f4c\"><strong>JavaScript: the Good Parts</strong></a></li>\n</ul>\n<br>\n<h2>22. David Walsh Blog</h2>\n<p><img src=\"/assets/other/david-walsh-blog.jpg\" alt=\"david-walsh-blog\"></p>\n<p>David Walsh Blog is a popular coding blog that focuses on modern libraries, programming tutorials, and shortcuts for programming. David Walsh with his guest writers are providing daily posts to help programmers to learn how to code quicker and more efficiently</p>\n<ul>\n<li><a href=\"https://davidwalsh.name/\"><strong>https://davidwalsh.name/</strong></a></li>\n</ul>\n<br>\n<h2>23. StackOverflow</h2>\n<p><img src=\"/assets/other/stack-overflow.jpg\" alt=\"stackoverflow\"></p>\n<p>StackOverflow is a question and answer web platform where developers help each other to solve problems. StackOverflow is maybe one of the best places where you can learn programming and at the same time, you can help other programmers but solving problems.</p>\n<ul>\n<li><a href=\"https://stackoverflow.com/\"><strong>https://stackoverflow.com/</strong></a></li>\n</ul>\n<br>\n<h2>24. GitHub</h2>\n<p><img src=\"/assets/other/github.jpg\" alt=\"github\"></p>\n<p>Another giant in the coding world like the StackOverflow is the Github. Github is primary version control systems but you can find a lot of examples of code from which you can learn a lot, you cannot be a good programmer if you cannot read code written by others.</p>\n<ul>\n<li><a href=\"https://github.com/\"><strong>https://github.com/</strong></a></li>\n</ul>\n<br>\n<h2>25. The Crazy Programmer</h2>\n<p><img src=\"/assets/other/the-crazy-programmer.jpg\" alt=\"the-crazy-programmer\"></p>\n<p>TheCrazyProgrammer is another nice blog in the programming world where you will find guides, tutorials, and examples on coding topics.</p>\n<ul>\n<li><a href=\"https://www.thecrazyprogrammer.com/\"><strong>https://www.thecrazyprogrammer.com/</strong></a></li>\n</ul>\n<br>\n<p><ad-incontent></ad-incontent></p>\n<h2>26. Soft Skills: The Software Developer’s Life Manual</h2>\n<img src=\"/assets/books/soft-skills-the-software-developer’s-life-manual.jpg\" style=\"height:250px;\" alt=\"soft-skills-the-software-developer’s-life-manual\"/>\n<p>Soft Skills: The Software Developer’s Life Manual by John Z. Sonmez is a unique guide book, offering great techniques and practices for a more satisfying life as a professional programmer. It has a wide range of important \"soft\" topics, from career and productivity to personal finance and even fitness and relationships. It's a different book that is not targeting programming itself but it is a very useful book.</p>\n<ul>\n<li><a href=\"https://www.amazon.com/gp/product/1617292397/ref=as_li_tl?ie=UTF8&#x26;camp=1789&#x26;creative=9325&#x26;creativeASIN=1617292397&#x26;linkCode=as2&#x26;tag=aleksandarvas-20&#x26;linkId=d9203d7777235a68b04517a814e40ca5\"><strong>Soft Skills: The Software Developer’s Life Manual</strong></a></li>\n</ul>\n<br>\n<h2>27. The Go Programming Language</h2>\n<img src=\"/assets/books/the-go-programming-language.jpg\" style=\"height:250px;\" alt=\"the-go-programming-language\"/>\n<p>The Go Programming Language by Alan A. A. Donovan, Brian W. Kernighan is a book about the new kid in the town Golang programming language. The language which was completely designed by Google and is growing at a very fast pace, with great demand in the job market.</p>\n<ul>\n<li><a href=\"https://www.amazon.com/gp/product/0134190440/ref=as_li_tl?ie=UTF8&#x26;camp=1789&#x26;creative=9325&#x26;creativeASIN=0134190440&#x26;linkCode=as2&#x26;tag=aleksandarvas-20&#x26;linkId=1c58c31eba7ff292c0d71815ee43a844\"><strong>The Go Programming Language</strong></a></li>\n</ul>\n<br>\n<h2>28. Head First Java</h2>\n<img src=\"/assets/books/head-first-java.jpg\" style=\"height:250px;\" alt=\"head-first-java\"/>\n<p>One more great book, if you want to learn Java programming language, is Head First Java by Kathy Sierra, Bert Bates, especially if Java is the first language you want to learn, this book is right for you. It has a great beginner-friendly writing style with very good coding examples and exercises. Highly recommended for entry-level Java programmers.</p>\n<ul>\n<li><a href=\"https://www.amazon.com/gp/product/0596009208/ref=as_li_tl?ie=UTF8&#x26;camp=1789&#x26;creative=9325&#x26;creativeASIN=0596009208&#x26;linkCode=as2&#x26;tag=aleksandarvas-20&#x26;linkId=46ffe60539d655eaf8ece3906726c68d\"><strong>Head First Java</strong></a></li>\n</ul>\n<br>\n<h2>29. Coursera</h2>\n<p><img src=\"/assets/other/coursera.jpg\" alt=\"coursera\"></p>\n<p>Coursera is an educational learning platform that offers massive open online courses (MOOCs). Coursera is great for programmers who want to achieve goals from career advancement to skills development. Coursera offers a couple of learning programs from courses, specializations, professional certificates, master-track certificate and degrees.</p>\n<ul>\n<li><a href=\"https://www.coursera.org/\"><strong>https://www.coursera.org/</strong></a></li>\n</ul>\n<br>\n<h2>30. Udemy</h2>\n<p><img src=\"/assets/other/udemy.jpg\" alt=\"udemy\"></p>\n<p>Udemy is maybe the most famous educational learning platform which offers various video learning materials of different programming languages and frameworks. It has very high-quality video tutorials which you can get it at very cheap prices.</p>\n<ul>\n<li><a href=\"https://www.udemy.com/\"><strong>https://www.udemy.com/</strong></a></li>\n</ul>\n<br>\n<p><ad-incontent></ad-incontent></p>\n<h2>31. Clean Architecture</h2>\n<img src=\"/assets/books/clean-architecture.jpg\" style=\"height:250px;\" alt=\"clean-architecture\"/>\n<p>Clean Architecture by Uncle Bob is one more great book that every programmer must-read. It will improve dramatically the way you structure and design your code, to achieve high levels of maintainability and correctness in your work.</p>\n<ul>\n<li><a href=\"https://www.amazon.com/gp/product/0134494164/ref=as_li_tl?ie=UTF8&#x26;camp=1789&#x26;creative=9325&#x26;creativeASIN=0134494164&#x26;linkCode=as2&#x26;tag=aleksandarvas-20&#x26;linkId=ebb0009a3c56a8500b28c02b3b14d6e9\"><strong>Clean Architecture</strong></a></li>\n</ul>\n<br>\n<h2>32. The Rust Programming Language</h2>\n<img src=\"/assets/books/the-rust-programming-language.jpg\" style=\"height:250px;\" alt=\"the-rust-programming-language\"/>\n<p>The Rust Programming Language by Steve Klabnik is the official book on Rust, an open-source, community-developed systems programming language that runs blazingly fast, prevents segfaults, and guarantees thread safety. This book is a go-to guide written by members of the Rust team.</p>\n<ul>\n<li><a href=\"https://www.amazon.com/gp/product/1718500440/ref=as_li_tl?ie=UTF8&#x26;camp=1789&#x26;creative=9325&#x26;creativeASIN=1718500440&#x26;linkCode=as2&#x26;tag=aleksandarvas-20&#x26;linkId=40dfda2810822f5adc32a813e2568092\"><strong>The Rust Programming Language</strong></a></li>\n</ul>\n<br>\n<h2>33. Programming Elixir: Functional |> Concurrent |> Pragmatic |> Fun</h2>\n<img src=\"/assets/books/programming-elixir.jpg\" style=\"height:250px;\" alt=\"programming-elixir\"/>\n<p>Programming Elixir: Functional |> Concurrent |> Pragmatic |> Fun by Dave Thomas will take you to another level, with this book not that you will learn the Elixir programming language but you will enter in the world of functional programming languages and will shape the way you think, making problem-solving much easier.</p>\n<ul>\n<li><a href=\"https://www.amazon.com/gp/product/1680502999/ref=as_li_tl?ie=UTF8&#x26;camp=1789&#x26;creative=9325&#x26;creativeASIN=1680502999&#x26;linkCode=as2&#x26;tag=aleksandarvas-20&#x26;linkId=687ea0334f451bfca3e002a6e256729c\"><strong>Programming Elixir: Functional |> Concurrent |> Pragmatic |> Fun</strong></a></li>\n</ul>\n<br>\n<p><ad-incontent></ad-incontent></p>\n<h2>Bonus Spot. CodeSpot</h2>\n<p><img src=\"/assets/other/codespot.jpg\" alt=\"code-spot\"></p>\n<p>And lastly the CodeSpot blog, here at the CodeSpot blog you will find news, examples, tutorials and other material to learn to code. As CodeSpot starter in September 2019, it is still a very young blog but we still try to publish great content every day to help developers in solving problems.</p>\n<ul>\n<li><a href=\"https://www.codespot.org/\"><strong>https://www.codespot.org/</strong></a></li>\n</ul>\n<p><em>If you find this article helpful please share it and thanks for reading.</em></p>","frontmatter":{"path":"/materials-to-learn-software-development/","date":"2019-11-28T14:25:49.619Z","title":"33 Best Materials to Learn Software Development in 2020","author":"Aleksandar Vasilevski","image":"/assets/books-2158737_1280.jpg","category":"Tools","tags":"#tools #resources","featured":false}}},{"node":{"id":"62839458-0193-50e7-a042-3fb487df8325","html":"<p><img src=\"/assets/cover/protocol-buffers.png\" alt=\"cover-photo\"></p>\n<h2>What are Protocol Buffers</h2>\n<p>Protocol buffers also known as Protobuf are an efficient and flexible mechanism for serializing structured data. Protobuf works in a way where you define the data to be structured once and then with a specially generated source code you can read and write your structured data.\nProtocol buffers are language-neutral and platform-neutral, at a time when this post is written they have support for Java, Python, Objective-C, and C++, also with the new proto3 language version, you can also use them with Dart, Go, Ruby, and C#, with more languages to come.</p>\n<p><ad-incontent></ad-incontent></p>\n<h2>How do Protocol Buffers work</h2>\n<p>We need to specify how we want the information that we are serializing to be structured by defining Protobuf message types in <code>.proto</code> files. Each Protobuf message is small information that contains a series of name-value pairs. Let's see a basic example of a proto file how looks like.</p>\n<pre><code class=\"language-java\">message Person {\n  required string name = 1;\n  required int32 id = 2;\n  optional string email = 3;\n\n  enum PhoneType {\n    MOBILE = 0;\n    HOME = 1;\n    WORK = 2;\n  }\n\n  message PhoneNumber {\n    required string number = 1;\n    optional PhoneType type = 2 [default = HOME];\n  }\n\n  repeated PhoneNumber phone = 4;\n}\n</code></pre>\n<p>As we can see the message format is very simple, each message type has one or more numbered fields, where each field has a name and a value type. The value types can be booleans, integer, floating-point, strings, raw bytes, or other protocol buffer message types, allowing you to structure your data hierarchically.\nWhen you finish defining the messages, you run the protocol buffer compiler for the particular application language that you are using on your proto file to generate data access classes. This will provide getters and setters for each field also methods to serialize/parse the structure to and from raw bytes.</p>\n<blockquote>\n<p>Note: Protocol Buffer classes are basically just data holders, they don't make good first class citizens in an object model. If you want to add richer behaviour to a generated class, the best way to do this is to wrap the protocol buffer class in an application-specific class.</p>\n</blockquote>\n<p><ad-incontent></ad-incontent></p>\n<h2>Protocol Buffers vs XML</h2>\n<p>Protobuf has many advantages over XML, let's see some of the pros.</p>\n<ul>\n<li>simpler</li>\n<li>3 to 10 times smaller</li>\n<li>20 to 100 times faster</li>\n<li>less ambiguous</li>\n<li>generate data access classes that are easier to use programmatically</li>\n</ul>\n<p>If we do a simple example in XML will look like:</p>\n<pre><code class=\"language-xml\">&#x3C;person>\n  &#x3C;name>John Doe&#x3C;/name>\n  &#x3C;email>jdoe@example.com&#x3C;/email>\n&#x3C;/person>\n</code></pre>\n<p>while the Protobuf message (protocol buffer text format) looks like:</p>\n<pre><code class=\"language-javascript\"># Textual representation of a protocol buffer.\n# This is *not* the binary format used on the wire.\nperson {\n  name: \"John Doe\"\n  email: \"jdoe@example.com\"\n}\n</code></pre>\n<p>When the above message is encoded to the Protobuf binary code format is 28 bytes long and will take around 100-200 nanoseconds to parse. For comparison, the XML version is at least 69 bytes and would take around 5,000-10,000 nanoseconds to parse.\nManipulating protocol buffer is also easier compared to XML. Let's see them both in the examples below.</p>\n<pre><code class=\"language-javascript\">cout &#x3C;&#x3C; \"Name: \" &#x3C;&#x3C; person.name() &#x3C;&#x3C; endl;\ncout &#x3C;&#x3C; \"E-mail: \" &#x3C;&#x3C; person.email() &#x3C;&#x3C; endl;\n</code></pre>\n<p><em>Protobuf manipulation</em></p>\n<pre><code class=\"language-xml\">cout &#x3C;&#x3C; \"Name: \"\n      &#x3C;&#x3C; person.getElementsByTagName(\"name\")->item(0)->innerText()\n      &#x3C;&#x3C; endl;\ncout &#x3C;&#x3C; \"E-mail: \"\n      &#x3C;&#x3C; person.getElementsByTagName(\"email\")->item(0)->innerText()\n      &#x3C;&#x3C; endl;\n</code></pre>\n<p><em>XML manipulation</em></p>\n<h2>Protobuf vs JSON</h2>\n<p>As we know JSON is a subset of the JavaScript programming language. Its messages are exchanged in human-readable text format and are completely independent and supported by almost all programming languages. On the other hand protocol buffers are not only a message format. It is a set of rules and tools that define and exchange messages. Currently is restricted to only some programming languages. Also, it has more data types than JSON, like methods, enumerates, and has other functions, including RPC (Remote Procedure Calls).</p>\n<p><strong>Advantages of Protobuf:</strong></p>\n<ul>\n<li>Smaller and faster</li>\n<li>RPC support</li>\n<li>Structure validation</li>\n</ul>\n<p><strong>Advantages of JSON:</strong></p>\n<ul>\n<li>Human readability</li>\n<li>More resources and support</li>\n<li>Bigger community</li>\n</ul>\n<h2>Conclusion</h2>\n<p>As Protocol buffers are a great modern method for serializing structured data they also offer some nice advantages over JSON and XML, while it is still not a full JSON replacement, protocol buffers offer its greatest advantages in terms of speed, encoding and decoding size of the data.</p>","frontmatter":{"path":"/protocol-buffers/","date":"2019-11-24T18:30:49.619Z","title":"Protocol Buffers an Alternate to JSON","author":"Aleksandar Vasilevski","image":"/assets/cover/protocol-buffers.png","category":"JavaScript","tags":"#protocolbuffers #protobuf #json #xml","featured":false}}},{"node":{"id":"c18cbe68-fd31-54e9-b984-8ed1e2a84d30","html":"<p><img src=\"/assets/cover/cpu-background.jpg\" alt=\"cover-photo\"></p>\n<h2>Introduction to CPU</h2>\n<p>CPU (central processing unit) or processor is electronic circuitry within a computer that is processing instructions by performing arithmetic, logic, controlling, and input/output (I/O) operations specified by the instructions. This cycle of performing operations by the CPU depends on its clock-rate, which is measured with Hz (Hertz), there are bigger units like kHz, MHz, GHz, etc.</p>\n<ul>\n<li>1Hz  - CPU will run the cycle once in a second</li>\n<li>1MHz - CPU will run 1 000 000 cycles in a second</li>\n<li>1GHz - CPU will run 1.000.000.000 cycles in a second</li>\n</ul>\n<h2>32 Bit and 64 Bit CPU</h2>\n<p>A 64-bit processor is capable of processing more data than a 32-bit processor because the 64-bit processor can store more computational values, memory addresses, etc, which means that 64-bit can access over four billion times physical memory than 32-bit.</p>\n<ul>\n<li>A 32-bit processor can handle a memory RAM size of 2^32 (4 GB)</li>\n<li>A 64-bit processor can handle a memory RAM size of 2^64 (16 Exabyte)</li>\n</ul>\n<p><ad-incontent></ad-incontent></p>\n<h2>Datatypes Size Example</h2>\n<p>Let's see a simple example in C programming language where we will print some datatypes.</p>\n<pre><code class=\"language-c\">#include &#x3C;stdio.h>\n#include &#x3C;limits.h>\n\nint main() {\n\n  printf(\"char\", sizeof(char));\n  printf(\"short\", sizeof(short));\n  printf(\"int\", sizeof(int));\n  printf(\"int 64 t\", sizeof(int64_t));\n  printf(\"float\", sizeof(float));\n  printf(\"double\", sizeof(double));\n  printf(\"long double\", sizeof(long double));\n\n  return 0;\n}\n</code></pre>\n<p>Here is the result that we got from running our program in C.</p>\n<pre><code>type          size in byte\nchar          1\nshort         2\nint           4\nint 64 t      8\nfloat         4\ndouble        8\nlong double   16\n</code></pre>\n<p>This means an int of 4 bytes on a 32-bit processor you can process a number in the range of 2^32. You can use the int64_t (which in this case the int is 8 bytes) on a 64-bit processor to use the whole range of 2^64.\nThis means the 32-bit processor can execute 4 bytes of data in one instruction cycle while 64-bit means that the processor can execute 8 bytes of data in one instruction cycle.</p>\n<p><ad-incontent></ad-incontent></p>\n<h2>Backward Compatible</h2>\n<p>On a computer with a 32-bit processor, you cannot have a 64-bit operating system installed, it can only run a 32-bit operating system. Where on the 64-bit processor you can have a 64-bit or 32-bit operating system, however, there is a downside of using 32-bit OS where the processor will not run at its full capability. If we talk about programs, you cannot run legacy 16-bit programs on a 64-bit processor, where many 32-bit programs are still compatible.</p>\n<h2>Conclusion</h2>\n<p>The 64-bit CPU is much more powerful than the 32-bit CPU, and it is becoming more and more common in computers, most of the users are now using 64-bit operating systems and programs.</p>","frontmatter":{"path":"/32-bit-and-64-bit-cpu/","date":"2019-11-19T16:00:49.619Z","title":"Introduction to 32 Bit and 64 Bit CPU","author":"Aleksandar Vasilevski","image":"/assets/cover/cpu-background.jpg","category":"Hardware","tags":"#cpu #hardware","featured":false}}},{"node":{"id":"4600ee73-a179-542f-b94b-68eb0900c0b0","html":"<p><img src=\"/assets/gatsby-cover.jpg\" alt=\"gatsby\"></p>\n<h2>What is Gatsby js</h2>\n<p>To build a blog today has become even more easy with the new <a href=\"https://jamstack.org/\"><strong>JAM Stack</strong></a> (JavaScript, API, and Markup). JAM Stack stands for\n<strong>A modern architecture - Create fast and secure sites and dynamic apps with JavaScript, APIs, and prerendered Markup, served without web servers.</strong></p>\n<p><ad-incontent></ad-incontent></p>\n<p><strong>Gatsby is a static site generator that is built on ReactJS.</strong> In its simplest definition, a static website is a group of HTML pages, which does not pull any data from a database when a viewer visits it. A static site looks the same for every visitor. Static sites are faster to load too, as the server sends the same response to every visitor. However, you can not customize content for visitors. Since Gatsby builds on top of React, you get all the benefits of React such as its performance, components, JSX, React library ecosystem and a large community. <a href=\"https://www.gatsbyjs.org/\"><em>Gatsby Documentation</em></a> is also very well written so you should not have any problems.\nIf you don't know React js, you can buy great React books from Amazon on the links below:</p>\n<ol>\n<li><a href=\"https://www.amazon.com/gp/product/1491954620/ref=as_li_tl?ie=UTF8&#x26;camp=1789&#x26;creative=9325&#x26;creativeASIN=1491954620&#x26;linkCode=as2&#x26;tag=aleksandarvas-20&#x26;linkId=e63aacd59b4ee5275c4cc1d21cfa5196\"><strong>Learning React: Functional Web Development with React and Redux</strong></a> by Alex Banks</li>\n<li><a href=\"https://www.amazon.com/gp/product/172004399X/ref=as_li_tl?ie=UTF8&#x26;camp=1789&#x26;creative=9325&#x26;creativeASIN=172004399X&#x26;linkCode=as2&#x26;tag=aleksandarvas-20&#x26;linkId=771ea64e7951363f6031778e0c92d0ad\"><strong>The Road to learn React: Your journey to master plain yet pragmatic React.js</strong></a> by Robin Wieruch</li>\n<li><a href=\"https://www.amazon.com/gp/product/013484355X/ref=as_li_tl?ie=UTF8&#x26;camp=1789&#x26;creative=9325&#x26;creativeASIN=013484355X&#x26;linkCode=as2&#x26;tag=aleksandarvas-20&#x26;linkId=831b989ef5917775dec64b5e31db68ec\"><strong>Learning React: A Hands-On Guide to Building Web Applications Using React and Redux (2nd Edition)</strong></a> by Kirupa Chinnathambi</li>\n</ol>\n<p>Or if you prefer to learn to React by building an app with step by step tutorial, you can start with this article: <a href=\"https://www.codespot.org/create-react-app-from-scratch-part-1/\"><strong>Create React App From Scratch Series</strong></a></p>\n<p>For many static websites, you will need to use external data sources during the build process. Gatsby provides support for many forms of data, including CMSs like WordPress, APIs, and Markdown. To access this data, Gatsby uses GraphQL.</p>\n<p><img src=\"/assets/gatsby-schema.png\" alt=\"gatsby\">\n<em>Gatsby js Schema</em></p>\n<p>If you know GraphQL, accessing data from Markdown using Gatsby feels easy. If GraphQL is new to you, it does add yet another thing to learn, however, the <a href=\"https://www.gatsbyjs.org/docs/querying-with-graphql\"><em>documentation</em></a> on using GraphQL with Gatsby has a lot of information.</p>\n<blockquote>\n<p>Note: GraphQL is a query language.</p>\n</blockquote>\n<p><ad-incontent></ad-incontent></p>\n<h2>Building a Blog With Gatsby js</h2>\n<p>To create a blog with gatsby js, we need to do a couple of steps. Let's see in the example below.</p>\n<h3>Install the Gatsby CLI</h3>\n<pre><code class=\"language-shell\">npm install -g gatsby-cli\n</code></pre>\n<h3>Create a new site</h3>\n<pre><code class=\"language-shell\">gatsby new gatsby-site\n</code></pre>\n<h3>Change directories into site folder</h3>\n<pre><code class=\"language-shell\">cd gatsby-site\n</code></pre>\n<h3>Start the development server</h3>\n<pre><code class=\"language-shell\">gatsby develop\n</code></pre>\n<p>After the four steps, your gatsby site will be ready, you can access the gatsby development environment at <code>localhost:8000</code> by default. You can edit JavaScript pages in the <code>src/pages</code> and the changes will be reloaded automatically in the browser.</p>\n<h3>Create a production build</h3>\n<pre><code class=\"language-shell\">gatsby build\n</code></pre>\n<p>With the build command, Gatsby will perform production build for your site, which in other words means generating static HTML pages.</p>\n<h3>Serve the production build locally</h3>\n<pre><code class=\"language-shell\">gatsby serve\n</code></pre>\n<p>Lastly, with the shell command, Gatsby will start local HTML server for testing your build site</p>\n<p><ad-incontent></ad-incontent></p>\n<h3>Gatsby project structure</h3>\n<p>With the Gatsby site installed you will get the default project structure, which is very simple with a couple of important config files to remember.</p>\n<pre><code class=\"language-javascript\">|-- /.cache\n|-- /plugins\n|-- /public\n|-- /src\n    |-- /pages\n    |-- /templates\n    |-- html.js\n|-- /static\n|-- gatsby-config.js\n|-- gatsby-node.js\n|-- gatsby-ssr.js\n|-- gatsby-browser.js\n</code></pre>\n<p><em>Gatsby js project structure</em></p>\n<p>There are four important files for gatsby site:</p>\n<ul>\n<li><strong>gatsby-config.js</strong> - configure options for Gatsby with metadata like title, description, etc.</li>\n<li><strong>gatsby-node.js</strong> - Gatsby Node.js API for customizing the default settings about the build process.</li>\n<li><strong>gatsby-browser.js</strong> - Gatsby browser API for customizing the default settings for the browser.</li>\n<li><strong>gatsby-ssr.js</strong> - Gatsby server-side rendering API for customizing the settings affecting server-side rendering.</li>\n</ul>\n<h3>Creating pages automatically</h3>\n<p>Gatsby will create pages automatically from the React components in <code>src/pages</code> into pages with URL addresses. For example, components index.js and about.js would automatically create pages for index page (/) and about page (/about).</p>\n<p><ad-incontent></ad-incontent></p>\n<h3>Gatsby js components</h3>\n<p>Gatsby js components are just React components, if you have basic React knowledge you would not have problems understanding them, let's see how does React component looks like in the next example.</p>\n<pre><code class=\"language-jsx\">import React from \"react\"\nconst AboutPage = () => (\n  &#x3C;main>\n    &#x3C;h1>About the Author&#x3C;/h1>\n    &#x3C;p>Welcome to my Gatsby site.&#x3C;/p>\n  &#x3C;/main>\n)\nexport default AboutPage\n</code></pre>\n<p><em>Gatsby js component</em></p>\n<p>In the example above we have a React functional component build with JSX, on the top we are importing the React, which after we have the about page with the HTML like structure inside, and at the end we are exporting the React component.</p>\n<blockquote>\n<p>JSX is a syntax extension to JavaScript for producing the React components.</p>\n</blockquote>\n<h3>Markdown</h3>\n<p>Gatsby can use markdown files or <code>.md</code> for creating pages in your web site. The markdown pages should be added to the pages folder, for example <code>/pages/posts</code>. The naming of the markdown files is best to be with <em>date-url</em> or just the <em>url</em> with the extension <code>.md</code> at the end.</p>\n<pre><code>---\npath: /how-to-build-a-blog-with-gatsby-and-netlify/\ntitle: How To Build A Blog With Gatsby and Netlify\nimage: /assets/gatsby-cover.jpg\nauthor: Aleksandar Vasilevski\ncategory: Gatsby\ntags: '#gatsby #netlify #cms #blog #jam #javascript #react'\ndate: 2019-09-19T11:00:00.619Z\n---\n//Here we just add the content in markdown format\n</code></pre>\n<p><em>Markdown file example</em></p>\n<p><ad-incontent></ad-incontent></p>\n<h2>Netlify CMS</h2>\n<p>With Netlify CMS you can add content more easy without manually editing the markdown files. To start <a href=\"https://www.gatsbyjs.org/docs/sourcing-from-netlify-cms/\"><em>Sourcing from Netlify CMS</em></a> you need to install the NPM package for the Netlify CMS.</p>\n<pre><code class=\"language-shell\">npm install netlify-cms\n</code></pre>\n<p>After the installing of the package, you will need to add the plugin to the <code>gatsby-config.js</code>, if the file is not there feel free to create it.</p>\n<pre><code class=\"language-javascript\">module.exports = {\n  plugins: [`gatsby-plugin-netlify-cms`],\n}\n</code></pre>\n<p>Finally, you’ll need to add a configuration file. The plugin you just installed will take care of creating the Netlify CMS app and outputting it, so you’ll want to put the configuration file in that same directory. </p>\n<pre><code class=\"language-yml\">backend:\n  name: test-repo\nmedia_folder: static/assets\npublic_folder: assets\ncollections:\n  - name: blog\n    label: Blog\n    folder: blog\n    create: true\n    fields:\n      - { name: path, label: Path }\n      - { name: date, label: Date, widget: datetime }\n      - { name: title, label: Title }\n      - { name: body, label: Body, widget: markdown }\n</code></pre>\n<p><em>Configuration file located in static/admin/config.yml</em></p>\n<h3>Saving to a Git Repo</h3>\n<p>To save content in a Git repo, the repo should be hosted on some service like GitHub and you will need to authenticate the service so the Netlify CMS can make changes to the content. To enable basic GitHub authentication you will need:</p>\n<ol>\n<li>Follow the authentication provider setup steps in the <a href=\"https://docs.netlify.com/visitor-access/oauth-provider-tokens/#using-an-authentication-provider\"><strong>Netlify</strong></a> docs.</li>\n<li>\n<p>Add the following lines of code to your Netlify CMS config.yml file:</p>\n<pre><code class=\"language-yml\">backend:\nname: github\nrepo: owner-name/repo-name # Path to your GitHub repository\n</code></pre>\n</li>\n</ol>\n<blockquote>\n<p>Note: You can add content manually by pushing the pages to your Git repo without any CMS. To do that just add the markdown pages to your <code>pages</code> folder.</p>\n</blockquote>\n<p><ad-incontent></ad-incontent></p>\n<h2>Deploying Gatsby site to Netlify</h2>\n<p>To deploy your Gatsby js site to Netlify, (You can find the full example here: <a href=\"https:/www.codespot.org/how-to-deploy-a-website-to-netlify\"><strong>How to Deploy A Website to Netlify</strong></a>) for static file hosting. </p>\n<p>Pros of using Netlify static file hosting:</p>\n<ul>\n<li>Cloud functions.</li>\n<li>Domain managment (with SSL).</li>\n<li>Form submissions</li>\n<li>a/b testing</li>\n<li>Clean user interface</li>\n</ul>\n<p>Once you’ve wired up Netlify to your repo, each push to your GitHub repository, automatically builds your website, according to the static site generator you’re using, and deploys it to production. The best part about Netlify is that it’s free. If you plan on building a small web site or blog it’s unlikely you’ll need to pay for anything.</p>\n<h2>Conclusion</h2>\n<p>In the previous years, you would need to use technologies like WordPress, Drupal, Joomla, etc, and with that, you would be needed to pay for server costs every month. While WordPress is still very good in terms of popularity, community, ease of use of the whole platform, JAM Stack or in our case Gatsby and Netlify CMS in its native form provides some excellent features as well.\nIf you find this article helpful please share it and thanks for reading.</p>","frontmatter":{"path":"/how-to-build-a-blog-with-gatsby-and-netlify/","date":"2019-11-17T14:30:00.619Z","title":"How To Build A Blog With Gatsby and Netlify","author":"Aleksandar Vasilevski","image":"/assets/gatsby-cover.jpg","category":"Gatsby","tags":"#gatsby #netlify #cms #blog #jam #javascript #react","featured":false}}},{"node":{"id":"2d666736-baf0-5d52-9150-de3d1df32a1d","html":"<p><img src=\"/assets/cover/javascript.png\" alt=\"javascript-logo\"></p>\n<p>In JavaScript try catch finally statement is a great way for handling errors that may occur in a block of code. In this article, we will learn about all three clauses.</p>\n<pre><code class=\"language-javascript\">try{\n  //do some code\n}catch(e){\n  //handle the exception\n}finally{\n  //do some code\n}\n</code></pre>\n<p><em>Simple Example of Try Catch Finally in JavaScript</em></p>\n<p><ad-incontent></ad-incontent></p>\n<p>The <strong>try</strong> statement has a try block, which inside we can have one or more statements. The <code>{}</code> are used to open and close the block they must be used even for a single statement. After the end of the try block, the catch clause or finally clause must be used, which we can have three forms for the try/catch/finally statement.</p>\n<ol>\n<li>try - catch</li>\n<li>try - finally</li>\n<li>try - catch - finally</li>\n</ol>\n<p>The <strong>catch</strong> clause has statements that what should be done if some sort of exception (error) is thrown in the try block. In other words first, do the try block if it is not successful (throws an exception) go to the catch block and do that (handle the exception). In case when the try block doesn't throw an exception, the catch clause will be skipped.</p>\n<p>The <strong>finally</strong> clause always executes after the try block and the catch clause.</p>\n<p><ad-incontent></ad-incontent></p>\n<h2>Unconditional catch clause</h2>\n<p>If an unconditional catch clause is used, the catch block will be executed if an exception is thrown.</p>\n<pre><code class=\"language-javascript\">try {\n  throw 'myException'; // generates an exception\n}\ncatch (e) {\n  // statements to handle any exceptions\n  logMyErrors(e); // pass exception object to error handler\n}\n</code></pre>\n<p><em>Unconditional Catch Clause (Source: MDN)</em></p>\n<p>Here we simply have thrown an exception in the try block, and we got the exception in the catch block, which is passed to the error handler.</p>\n<blockquote>\n<p>Note: you can use any parameter name instead of <code>e</code></p>\n</blockquote>\n<h2>Conditional catch clause</h2>\n<p>If you want to handle specific exceptions, you can use more than one catch clauses. The try block can throw three types of exceptions: TypeError, RangeError, and EvalError. When an exception is thrown, an appropriate catch clause will be used to handle the exception. If the thrown exception is not specified, and the unconditional clause is found, then the exception will be handled there.</p>\n<pre><code class=\"language-javascript\">try {\n  myroutine(); // may throw three types of exceptions\n} catch (e if e instanceof TypeError) {\n  // statements to handle TypeError exceptions\n} catch (e if e instanceof RangeError) {\n  // statements to handle RangeError exceptions\n} catch (e if e instanceof EvalError) {\n  // statements to handle EvalError exceptions\n} catch (e) {\n  // statements to handle any unspecified exceptions\n  logMyErrors(e); // pass exception object to error handler\n}\n</code></pre>\n<p><em>Not Recommended Conditional Catch Clause</em></p>\n<blockquote>\n<p> This feature is non-standard and is not on a standards track. Do not use it on production sites facing the Web: it will not work for every user. There may also be large incompatibilities between implementations and the behavior may change in the future - <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/try...catch\"><strong>MDN</strong></a>.</p>\n</blockquote>\n<p>There is a great alternative where a conditional catch clause can be used. Let's see the next example.</p>\n<pre><code class=\"language-javascript\">try {\n  myroutine(); // may throw three types of exceptions\n} catch (e) {\n  if (e instanceof TypeError) {\n    // statements to handle TypeError exceptions\n  } else if (e instanceof RangeError) {\n    // statements to handle RangeError exceptions\n  } else if (e instanceof EvalError) {\n    // statements to handle EvalError exceptions\n  } else {\n    // statements to handle any unspecified exceptions\n    logMyErrors(e); // pass exception object to error handler\n  }\n}\n</code></pre>\n<p><em>Recommended Conditional Catch Clause</em></p>\n<p>Here we have a catch clause, and inside we have an if-else statement where we check for the type of the exception that is thrown.</p>\n<h2>The finally clause</h2>\n<p>The finally clause is the last statement that will execute after the try block and catch clause.</p>\n<pre><code class=\"language-javascript\">openMyFile();\ntry {\n  // tie up a resource\n  writeMyFile(theData);\n}\nfinally {\n  closeMyFile(); // always close the resource\n}\n</code></pre>\n<p><em>Finally Clause</em></p>\n<blockquote>\n<p>Note: The finally clause will execute regardless of whether an exception is thrown</p>\n</blockquote>\n<p><ad-incontent></ad-incontent></p>\n<h2>Browser support</h2>\n<table>\n<thead>\n<tr>\n<th>Chrome</th>\n<th>Firefox</th>\n<th>Safari</th>\n<th>IE/Edge</th>\n<th>Opera</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<td>Yes</td>\n<td>Yes</td>\n<td>Yes</td>\n<td>Yes</td>\n<td>Yes</td>\n</tr>\n</tbody>\n</table>\n<p>I hope now you understand how the try/catch/finally works in JavaScript if you find this article useful please share it.</p>","frontmatter":{"path":"/javascript-try-catch-finally/","date":"2019-11-14T12:30:49.619Z","title":"How to Use JavaScript Try Catch Finally Statement","author":"Aleksandar Vasilevski","image":"/assets/cover/javascript.png","category":"JavaScript","tags":"#javascript","featured":false}}},{"node":{"id":"19fd3cce-155c-5db7-9b3c-a300b598fb7f","html":"<p><img src=\"/assets/cover/javascript.png\" alt=\"css-logo\"></p>\n<p>JavaScript array is a data structure that can hold one or more elements. The JavaScript array is mostly used to store elements and to organize them, so the values can be sorted or searched efficiently. In JavaScript, an array can hold different types of elements (numbers, strings, etc), but it is good practice all of the elements in the array to be the same type, so we can easily organize them as we want.</p>\n<p>One of the many important things about an array in JavaScript is to sort the elements stored in the array. To do the JavaScript array sort, we need to create an array and insert some elements in it. To sort the array we will use the <code>sort()</code> method that returns the sorted array as default with ascending order.</p>\n<p><ad-incontent></ad-incontent></p>\n<h2>Sorting Array of Strings</h2>\n<p>Let's see how we can sort an array of strings.</p>\n<pre><code class=\"language-javascript\">//here we have declared and initialized an array with strings\nconst strings = [\"B\", \"A\", \"D\", \"C\"];\nstrings.sort();\nconsole.log(strings); //output: [\"A\",\"B\",\"C\",\"D\"]\n</code></pre>\n<p>As we see in our example above, the strings were sorted in alphabet order because the strings are sorted by comparing them in UTF-16 code units.</p>\n<blockquote>\n<p>Note: UTF-16 is a character encoding format.</p>\n</blockquote>\n<h2>Sorting Array of Numbers</h2>\n<p>Let's see how we can sort an array of numbers.</p>\n<pre><code class=\"language-javascript\">//here we have declared and initialized an array with numbers\nconst numbers = [1, 20, 5, 300, 80, 1000];\nnumbers.sort();\nconsole.log(numbers); //output: [1,1000,20,300,5,80]\n</code></pre>\n<p>As we see in our example above, the output is not what we have expected. Let's take a closet look at how the JavaScript array sort method is working. To sort the elements in the array, the <code>sort()</code> method casts every element to string and then compares the given strings to determine the correct order of the elements, and we got the output for compared string values. This way most of the time if we sort numbers using the sort method by default it is not what we want.</p>\n<p>To compare the items as numbers we need to pass a compare function that have two arguments (a and b) and should return 1 if the first number is larger, 0 if they are equal, and -1 if the second number is larger.\nLet's create a comparison function for numbers.</p>\n<pre><code class=\"language-javascript\">function sortNumbers(a, b) {\n  if (a > b) {\n    return 1;\n  } else if (b > a) {\n    return -1;\n  } else {\n    return 0;\n  }\n}\n</code></pre>\n<p>Now let's call the sort method again, now with the comparison function <code>sortNumbers()</code> as argument.</p>\n<pre><code class=\"language-javascript\">const numbers = [1, 20, 5, 300, 80, 1000];\nnumbers.sort(sortNumbers); // output: [1,5,20,80,300,1000]\n</code></pre>\n<p>There is a much shorter way to write the comparison function.</p>\n<pre><code class=\"language-javascript\">numbers.sort((a, b) => a - b);\n</code></pre>\n<p><ad-incontent></ad-incontent></p>\n<p>As you see now we have sorted the numbers as we expected. To do the sorting in descending order you need just to replace the -1 with 1 and the same 1 with -1. JavaScript array sort method is a great way to sort elements, the time and complexity of the sort method depends on the implementation.</p>","frontmatter":{"path":"/javascript-array-sort/","date":"2019-11-12T21:00:49.619Z","title":"Guide to JavaScript Array Sort Method","author":"Aleksandar Vasilevski","image":"/assets/cover/javascript.png","category":"JavaScript","tags":"#javascript","featured":false}}},{"node":{"id":"83652500-96f0-5a88-9897-7c21a19404f0","html":"<p><img src=\"/assets/cover/computer-motherboard-memory.jpg\" alt=\"cover-photo\"></p>\n<h2>What is Register, Heap and Stack in Java</h2>\n<p>In this article, we will see how does the Java programming language is doing memory management, we will look at registers, stack, heap, constants, non-ram memory, and the famous Java garbage collector. Let's start with the fastest storage in Java the register.</p>\n<p><ad-incontent></ad-incontent></p>\n<h3>Register</h3>\n<p>The register is the fastest storage, because it exists in a different place from the other storages, in the processor. However, the number of available registers is very limited. As a developer, you don't have direct control at the registers, for comparison in C and C++ you can suggest register allocation.</p>\n<h3>Stack</h3>\n<p>The stack is located in the random-access memory (RAM) with direct support from the processor via its stack pointer. The stack pointer is moving up and down when it is going down it is creating a new memory and when it is going up it is releasing memory. This process is a very fast and great way to allocate storage, just the registers are faster in comparison.  </p>\n<h3>Heap</h3>\n<p>The heap is the general-purpose pool of memory, it is also located in the random-access memory (RAM), the heap is the place where all Java objects live. The heap is a very flexible memory you can simply create a new object on the heap by writing the keyword <code>new</code> and the storage will be allocated on the heap when that code will be executed. The price for the flexibility is that the heap is generally slower than the stack, that's why it can take more time to allocate and the garbage collector to clean up the heap storage.</p>\n<h3>Constant</h3>\n<p>Constant value lives directly in the code because they never change, that's why they are called constants after all.</p>\n<h3>Non-RAM</h3>\n<p>There is a data that can live outside of our program, the two best examples are streamed objects, which are turned into the stream of bytes and sent to other machine and persistent objects, which the objects live on the disk so they hold their state even when the program is not running, and they can be resurrected into a regular random-access memory object when they are needed.</p>\n<h2>Java Garbage Collector</h2>\n<p>Garbage Collector in Java is running in the background and looks into all objects that are in the memory to find out objects that are not referenced. Every unreferenced objects that are found are deleted so the space can be allocated for other objects. Unlike other languages such as C where memory allocation and deallocation it's manually, in Java it's done automatically by default. Objects in Java can be unreferenced by nulling the reference, by assigning the reference to another or by anonymous object. Memory management in Java is a very broad topic here we are just scratching the surface.</p>\n<p><ad-incontent></ad-incontent></p>\n<h2>Memory Management in Java example</h2>\n<pre><code class=\"language-java\">public class Memory {\n\n  public static void main(String[] args) { // Line 1\n    int i = 1; // Line 2\n    Object obj = new Object(); // Line 3\n    Memory mem = new Memory(); // Line 4\n    mem.foo(obj); // Line 5\n  } // Line 9\n\n  private void foo(Object param) { // Line 6\n    String str = param.toString(); //// Line 7\n    System.out.println(str);\n  } // Line 8\n\n}\n</code></pre>\n<p>In the image below we can see the stack and the heap with reference from the program above.</p>\n<p><img src=\"/assets/java-heap-and-stack-memory.png\" alt=\"heap-and-stack-memory\">\n<em>Java Memory Management Schema (Source: journaldev.com)</em></p>\n<p>Now let's see line by line the above Java program.</p>\n<ol>\n<li>Java runtime creates stack memory for the <code>main()</code> method thread.</li>\n<li>We are declaring and initializing a primitive local variable, it is stored in the stack memory of <code>main()</code> method thread.</li>\n<li>We are declaring and initializing a new object, it is stored on the heap memory and the stack memory holds the reference to it.</li>\n<li>Like on the line before we are doing the same here but with a different type.</li>\n<li>We are calling <code>foo()</code> and a block on the top of the stack is created to be used by the <code>foo()</code> method, and we pass the <code>obj</code>.</li>\n<li>Java is passed by value, a new reference to the object is created in the <code>foo()</code> stack block.</li>\n<li>A new string object is declared and initialized and it is stored on the heap in and the reference is created in the <code>foo()</code> stack.</li>\n<li><code>foo()</code> method is finished, and the memory allocated for <code>foo()</code> on the stack has become free.</li>\n<li><code>main()</code> method is finished, and the memory allocated for <code>main()</code> on the stack has become free.</li>\n</ol>\n<p><ad-incontent></ad-incontent></p>\n<h2>Conclusion</h2>\n<p>Memory management in Java is a very interesting topic but very broad topic too, Java itself will manage the memory without major interventions by the programmer, but knowing how memory work in will give you the advantage of writing good and optimized code in terms of memory usage, finding and fixing memory leaks.</p>","frontmatter":{"path":"/memory-management-in-java/","date":"2019-11-08T17:00:49.619Z","title":"Memory Management in Java","author":"Aleksandar Vasilevski","image":"/assets/cover/computer-motherboard-memory.jpg","category":"Java","tags":"#java #memory","featured":false}}},{"node":{"id":"18a37e99-6f3c-5f42-9f7e-b6cbc3c34fb6","html":"<p><img src=\"/assets/cover/thinking-in-java.jpg\" alt=\"thinking-in-java-cover\"></p>\n<p>Thinking in Java was written in 1998 by Bruce Eckel, and the latest 4th edition was published in 2006. The book till today is one of the most popular books about the Java programming language and object-oriented programing. Thinking in Java was the first book I have read about programming, It was a recommended book by the local university for Software Engineering and Computer Science. The book introduced me to the basics of java and object-oriented programming in general.</p>\n<p><ad-incontent></ad-incontent></p>\n<h2>Topics covered</h2>\n<p>Thinking in Java covers almost every basic aspect of the Java programming language, if you are beginner it will give you good building blocks of the programming in general as it keeps the level to be beginner-friendly but at the same time, it delivers a deep understanding of the Java programming language and object-oriented programming in general. Every topic is very good covered with clear coding examples and a couple of challenging exercises at the end of every chapter.\nThe first quarter of the book is mostly introduction to the Java programming language and how Java is working under the hood as it coverts topics like: </p>\n<pre><code>- Primitive values, classes, and objects, operators.\n- Access control modifiers for class methods and fields.\n- Heap, stack and garbage collection.\n- Constructors.\n- Polymorphism and interfaces.\n</code></pre>\n<p>The next three quarters are mostly going deeper into the Java programming language and the object-oriented programming and you will read on topics like:</p>\n<pre><code>- Inner classes.\n- Exceptions.\n- Generics.\n- Java Collections (Map, Set, List, etc.).\n- Enum and Annotations.\n- Input and Output\n- Concurrency.\n- Graphical user interface.\n</code></pre>\n<p>The latest 4th edition of the book covers up to Java 5 version, the later versions are not covered, but it is expected as the 4th edition is published in 2006. The book is a little over 1000 pages and as it is a great learning resource also you can use it as a reference book.</p>\n<iframe style=\"width:120px;height:240px;\" marginwidth=\"0\" marginheight=\"0\" scrolling=\"no\" frameborder=\"0\" src=\"//ws-na.amazon-adsystem.com/widgets/q?ServiceVersion=20070822&OneJS=1&Operation=GetAdHtml&MarketPlace=US&source=ac&ref=tf_til&ad_type=product_link&tracking_id=aleksandarvas-20&marketplace=amazon&region=US&placement=0131872486&asins=0131872486&linkId=4a51badcea26a7019af3aaf13aa19310&show_border=false&link_opens_in_new_window=false&price_color=333333&title_color=0066c0&bg_color=ffffff\">\n    </iframe>\n<h2>Conclusions</h2>\n<p>Thinking in Java is a must-read book, especially if you want to do programming in Java programing language or learn Object-Oriented Programming (OOP). The book is great for beginners and even experienced developers who want to gain deeper knowledge or are coming from other programming paradigms to object orientated programming.</p>\n<p>You can find and purchase Thinking in Java on the link below on Amazon</p>\n<p><a href=\"https://www.amazon.com/gp/product/0131872486/ref=as_li_tl?ie=UTF8&#x26;camp=1789&#x26;creative=9325&#x26;creativeASIN=0131872486&#x26;linkCode=as2&#x26;tag=aleksandarvas-20&#x26;linkId=b716cf92a9d842ca7bcac66c2e6a6c5a\"><strong>Thinking in Java</strong></a> by Bruce Eckel</p>\n<p><a target=\"_blank\"  href=\"https://www.amazon.com/gp/product/0131872486/ref=as_li_tl?ie=UTF8&camp=1789&creative=9325&creativeASIN=0131872486&linkCode=as2&tag=aleksandarvas-20&linkId=efd6893b878cb433848afb0b4a241cad\"><img border=\"0\" style=\"margin:auto; display:block\" src=\"//ws-na.amazon-adsystem.com/widgets/q?_encoding=UTF8&MarketPlace=US&ASIN=0131872486&ServiceVersion=20070822&ID=AsinImage&WS=1&Format=_SL250_&tag=aleksandarvas-20\" ></a><img src=\"//ir-na.amazon-adsystem.com/e/ir?t=aleksandarvas-20&l=am2&o=1&a=0131872486\" width=\"1\" height=\"1\" border=\"0\" alt=\"\" style=\"border:none !important; margin:0px !important;\" /></p>","frontmatter":{"path":"/review-thinking-in-java/","date":"2019-11-07T21:15:49.619Z","title":"Thinking in Java","author":"Aleksandar Vasilevski","image":"/assets/cover/thinking-in-java.jpg","category":"Books","tags":"#java #book #review","featured":false}}},{"node":{"id":"92388e6e-dece-56ae-8ff9-107fa261e682","html":"<p><img src=\"/assets/cover/peer-to-peer-network.jpg\" alt=\"javascript-logo\"></p>\n<p>Peer to peer or simply p2p is a decentralized network communications model where the peers are computer systems connected with each other. Interesting thing is that with peer to peer communication is done without a central system (Server), in other words, every peer in the network is a server and a client. Pros of using peer to peer (p2p) are protecting user privacy, lower server costs, etc. Torrents are an example of an anonymous p2p protocol where files are hosted for others to download them.</p>\n<p><ad-incontent></ad-incontent></p>\n<ul>\n<li>\n<p><strong>Advantages</strong></p>\n<ol>\n<li>No need for expensive server, and for network manager.</li>\n<li>Less network traffic than centralized client/server network.</li>\n<li>Extremly scalable, adding new peers is very easy.</li>\n<li>Difficult to take down, if you shot down couple of the peers, the other continue to work.</li>\n</ol>\n</li>\n<li>\n<p><strong>Disadvantages</strong></p>\n<ol>\n<li>The data is not organized into specific shared area, sometimes it might be hard to locate the files.</li>\n<li>There is litle to no security.</li>\n</ol>\n</li>\n</ul>\n<h2>How peer-to-peer (p2p) network works</h2>\n<p>In a standard centralized network when a user downloads a file, the user opens a web browser, visit the URL where the file is located and downloads the file. In this case, the website acts as a server and the user computer as a client that receives the data. This is the one-way data transfer where downloaded files are transferred from point A, the server to point B, the user.</p>\n<img src=\"https://upload.wikimedia.org/wikipedia/commons/thumb/f/fb/Server-based-network.svg/800px-Server-based-network.svg.png\" style=\"display:block; margin:auto;\" alt=\"client-server-network\" width=\"400\"/>\n<p><em>A network based on the client-server model (Source: Wikipedia)</em></p>\n<p>When the same file is downloaded through a peer-to-peer network, the process is handled differently. Here the user has to pre-install peer-to-peer software, which creates a virtual network of peer-to-peer users when the user downloads the file is received in bits that are transferred from other peers in the network that already has the file.\nAt the same time as the data is received, it is also sent to the other peers in the network that ask for it. This situation is different because it is a two-way data transfer.</p>\n<img src=\"https://upload.wikimedia.org/wikipedia/commons/thumb/3/3f/P2P-network.svg/800px-P2P-network.svg.png\" style=\"display:block; margin:auto;\" alt=\"peer-to-peer-network\" width=\"400\"/>\n<p><em>A peer-to-peer (P2P) network (Source: Wikipedia)</em></p>\n<h2>Architecture of peer-to-peer network</h2>\n<p>Every peer in peer-to-peer network architecture has the same responsibilities, every peer is a server and a client. We can classify a peer-to-peer network in three types unstructured, structured and hybrid networks where they are between the two.</p>\n<p>The <strong>unstructured peer-to-peer networks</strong> doesn't have a particular structure on the overlay network design. They are formed by nodes randomly from connection to each other. Because there is no structure, unstructured peer-to-peer networks are easy to build but are not very efficient.</p>\n<img src=\"https://upload.wikimedia.org/wikipedia/en/f/fa/Unstructured_peer-to-peer_network_diagram.png\" style=\"display:block; margin:auto;\" alt=\"client-server-network\" width=\"400\"/>\n<p><em>Overlay network diagram for an unstructured P2P network (Source: Wikipedia)</em></p>\n<p>In <strong>structured peer-to-peer networks</strong> the overlay is organized, and every node can efficiently search the network for the desired data. </p>\n<img src=\"https://upload.wikimedia.org/wikipedia/commons/7/79/Structured_%28DHT%29_peer-to-peer_network_diagram.png\" style=\"display:block; margin:auto;\" alt=\"client-server-network\" width=\"400\"/>\n<p><em>Overlay network diagram for a structured P2P network (Source: Wikipedia)</em></p>\n<p><ad-incontent></ad-incontent></p>\n<h2>Conclusion</h2>\n<p>Peer-to-peer is a technology born and based on a very simple principle, and that is decentralization. There are a lot of people for it and against it because of distributing copyrighted content unlawfully. However peer-to-peer as a concept has inspired many new philosophies in many areas of human interaction.</p>","frontmatter":{"path":"/introduction-to-peer-to-peer-network/","date":"2019-11-06T10:50:49.619Z","title":"Introduction to Peer to Peer (P2P) Network","author":"Aleksandar Vasilevski","image":"/assets/cover/peer-to-peer-network.jpg","category":"Network","tags":"#p2p #network","featured":false}}},{"node":{"id":"f77f8e21-0264-5f6f-93bc-7a031d18a699","html":"<p><img src=\"/assets/cover/web-cables.jpg\" alt=\"axios-http-client\"></p>\n<p>Axios is an HTTP client, build for communication between the front-end and the back-end, also Axios js can be used on the server-side with Node.js. There are a couple of other ways to do the communication, the most common are <a href=\"https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API\"><strong>Fetch API</strong></a>, <a href=\"https://api.jquery.com/jquery.ajax/\"><strong>jQuery Ajax</strong></a> and <a href=\"https://github.com/axios/axios\"><strong>Axios</strong></a>. In the past jQuery's Ajax was the most used standard for communication, but developers are moving away from it in favor of native APIs, and if you use frameworks like React Axios is more or less used in most of the cases. In this article, we will look at Axios an HTTP based client.</p>\n<h2>What is Axios js</h2>\n<p>Axios is promise-based, same as the Fetch but it is much more powerful and flexible over the native Fetch API. Here are the major features of Axios:</p>\n<p><em>Transform request and response</em></p>\n<p><em>Intercept request and response</em></p>\n<p><em>Make http requests from node js</em></p>\n<p><em>Cancel requests</em></p>\n<p><em>Automatic transforms for JSON data</em></p>\n<p><em>Make XMLHttpRequests from the browser</em></p>\n<p><em>Supports the Promise API</em></p>\n<p><em>Client-side support for protecting against XSRF</em></p>\n<p><em>Great for web frameworks like React, React Native, etc</em></p>\n<p><ad-incontent></ad-incontent></p>\n<h2>How to Install Axios js</h2>\n<p>Axios js can be installed with couple of methods (Axios NPM, bower, yarn, cdn) let's see how to install Axios examples:</p>\n<p>npm:\n<code>$ npm install axios</code></p>\n<p>bower:\n<code>$ bower install axios</code></p>\n<p>yarn:\n<code>$ yarn add axios</code></p>\n<p>cdn:\n<code>&#x3C;script src=\"https://unpkg.com/axios/dist/axios.min.js\">&#x3C;/script></code></p>\n<h2>Requests</h2>\n<p>Making an HTTP request with Axios is very easy. In its basic form, the object must have a URL property; if there is no method provided, GET will be used by default as a value. Let’s look at a simple Axios request example:</p>\n<pre><code class=\"language-javascript\">// POST request\naxios({\n  method: 'post',\n  url: '/signin',\n  data: {\n    firstName: 'John',\n    lastName: 'Smith'\n  }\n});\n</code></pre>\n<p><em>Axios post example</em></p>\n<p>In the example above we are simply telling the client to send a POST request to <code>/login</code> with a data object of key-value pairs as its data. Axios will do the conversion of the data to JSON format and send it as the request body.\nAlso we have out of the box methods for performing different types of requests. Let's take a look at a couple of the provided methods.</p>\n<p><em>axios.get</em></p>\n<p><em>axios.post</em></p>\n<p><em>axios.put</em></p>\n<p><em>axios.patch</em></p>\n<p><em>axios.delete</em></p>\n<p>Let's modify the code of the previous example with the <code>axios.post</code> method.</p>\n<pre><code class=\"language-javascript\">axios.post('/signin', {\n    firstName: 'John',\n    lastName: 'Smith'\n});\n</code></pre>\n<p><em>Axios post example</em></p>\n<p>We can also send custom headers with Axios. To send custom headers we simply need to pass an object with the headers as the last argument in the method.</p>\n<pre><code class=\"language-javascript\">const options = {\n  headers: {'X-Custom-Header': 'value'}\n};\n\naxios.post('/signin', { \n    firstName: 'John',\n    lastName: 'Smith'\n  }, options);\n</code></pre>\n<p><em>Axios post example with options</em></p>\n<p><ad-incontent></ad-incontent></p>\n<h2>Responses</h2>\n<p>As Axios is a promise-based client once the HTTP request is made Axios will return a promise that is fulfilled or rejected. We will use the Async/Await JavaScript feature (if you are not familiar with the Async/Await you can read more about it at <a href=\"https://www.codespot.org/async-javascript-part-3-async-await/\"><em>Async JavaScript Part 3: Async/Await</em></a> to handle the response, but if you are not familiar with it you can use the <code>then()</code> method.</p>\n<pre><code class=\"language-javascript\">signIn = async () => {\n  try{\n    let res = await axios.post(\"/signin\", {\n      firstName: 'John',\n      lastName: 'Smith'\n    });\n  }catch(e){\n    //handle the error\n  }\n};\n</code></pre>\n<p><em>Axios response example</em></p>\n<p>If the promise is fulfilled we will get the response in the <code>res</code> else if it is rejected we will get the error in our catch block. The fulfilled response object from the request contains the following information:</p>\n<pre><code class=\"language-javascript\">{\n  // `data` is the response that was provided by the server\n  data: {},\n \n  // `status` is the HTTP status code from the server response\n  status: 200,\n \n  // `statusText` is the HTTP status message from the server response\n  statusText: 'OK',\n \n  // `headers` the headers that the server responded with\n  // All header names are lower cased\n  headers: {},\n \n  // `config` is the config that was provided to `axios` for the request\n  config: {},\n \n  // `request` is the request that generated this response\n  // It is the last ClientRequest instance in node.js (in redirects)\n  // and an XMLHttpRequest instance the browser\n  request: {}\n}\n</code></pre>\n<p><em>Axios Response Schema (Source: npmjs)</em></p>\n<p><ad-incontent></ad-incontent></p>\n<h2>Transform request and response</h2>\n<p>Axios automatically transforms request and responses to JSON, but in some cases, if we need to send formats like CSV or XML we can override the default behavior and define a different transformation. To change the request data before sending it to the server, we need to set the <code>transformRequest</code> property in the config object (this method only works for POST, PUT, PATCH).</p>\n<pre><code class=\"language-javascript\">const options = {\n  method: 'post',\n  url: '/signin',\n  data: {\n    firstName: 'John',\n    lastName: 'Doe'\n  },\n  transformRequest: [(data, headers) => {\n    // transform the data\n    return data;\n  }]\n};\n\n// send the request\naxios(options);\n</code></pre>\n<h2>Intercept request and response</h2>\n<p>Intercept look similar to transform, but unlike transforms, which only receive the data and headers as arguments, interceptors receive the entire response object or request config and can change the HTTP request. You can make a request interceptor in Axios like in the next example.</p>\n<pre><code class=\"language-javascript\">// request interceptor\naxios.interceptors.request.use(config => {\n  // perform a task before the request is sent\n  console.log('Request was sent');\n  return config;\n}, error => {\n  // handle the error\n  return Promise.reject(error);\n});\n\n// send a get request\nsignIn = async () => {\n  try{\n    let res = await axios.get(\"/some_endpoint\");\n  }catch(e){\n    //handle the error\n  }\n};\n</code></pre>\n<p><em>Axios interceptors example</em></p>\n<p>Here we are logging a message when a request is sent and we wait for a response from the server. With interceptors, it is no longer needed to implement tasks for each HTTP request.\nResponse interceptor is also provided, which allows us to transform the responses.</p>\n<pre><code class=\"language-javascript\">// response interceptor\naxios.interceptors.response.use((response) => {\n  // do something with the response data\n  console.log('Response was received');\n  return response;\n}, error => {\n  // handle the response error\n  return Promise.reject(error);\n});\n\n// send a get request\nsignIn = async () => {\n  try{\n    let res = await axios.get(\"/some_endpoint\");\n  }catch(e){\n    //handle the error\n  }\n};\n</code></pre>\n<p><em>Axios interceptors example</em></p>\n<p><ad-incontent></ad-incontent></p>\n<h2>Cancel requests</h2>\n<p>Sometimes you may want to cancel a request that is already sent, Axios allows us to cancel a request by using a cancel token.</p>\n<pre><code class=\"language-javascript\">const source = axios.CancelToken.source();\n\nsomefunc = async () => {\n  try{\n    let res = await axios.get(\"/some_endpoint\");\n  }catch(e){\n    if(axios.isCancel(thrown)) {\n      console.log(thrown.message);\n    }else{\n      //handle the error\n    }\n  }\n};\n\n// cancel the request (the message parameter is optional)\nsource.cancel('Request canceled.');\n</code></pre>\n<p><em>Axios cancel request example</em></p>\n<h2>Automatic transforms for JSON data</h2>\n<p>Axios automatically convert requests and responses to JSON, but in some cases, if we want to we can override the default transformation and define other data formats like CSV or XML. To change the default behavior of Axios we need to set the <code>tranasformRequest</code> property in the config (This method only works for POST, PUT and PATCH requests). Let's check the next example of how to change the default transformation in Axios.</p>\n<pre><code class=\"language-javascript\">const options = {\n  method: 'post',\n  url: '/signin',\n  data: {\n    firstName: 'John',\n    lastName: 'Doe'\n  },\n  transformRequest: [(data, headers) => {\n    // transform the data\n    return data;\n  }]\n};\n\n// send the request\naxios(options);\n</code></pre>\n<p><em>Axios transforms example</em></p>\n<p>To transform the data before sending it, we can set a <code>transformResponse</code> property in the config.</p>\n<pre><code class=\"language-javascript\">const options = {\n  method: 'post',\n  url: '/signin',\n  data: {\n    firstName: 'John',\n    lastName: 'Doe'\n  },\n  transformResponse: [(data) => {\n    // transform the response\n\n    return data;\n  }]\n};\n\n// send the request\naxios(options);\n</code></pre>\n<p><em>Axios transforms example</em></p>\n<p><ad-incontent></ad-incontent></p>\n<h2>Client-side support for protecting against XSRF</h2>\n<p>Axios offer good protection against XSRF (Cross-site request forgery) attacks by allowing you to add additional auth data when making requests. With this feature, the server can discover the requests that are coming from unauthorized locations. We can see how we can achieve this protection in the following example.</p>\n<pre><code class=\"language-javascript\">const options = {\n  method: 'post',\n  url: '/signin',\n  xsrfCookieName: 'XSRF-TOKEN',\n  xsrfHeaderName: 'X-XSRF-TOKEN',\n};\n\n// send the request\naxios(options);\n</code></pre>\n<p><em>Axios protection against XSRF example</em></p>\n<h2>Browser support</h2>\n<p>Axios js has great browser support even for older browsers, you can check the browser support on the table below.</p>\n<table>\n<thead>\n<tr>\n<th>Chrome</th>\n<th>Firefox</th>\n<th>Safari</th>\n<th>IE</th>\n<th>Edge</th>\n<th>Opera</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<td>Yes</td>\n<td>Yes</td>\n<td>Yes</td>\n<td>11+</td>\n<td>Yes</td>\n<td>Yes</td>\n</tr>\n</tbody>\n</table>\n<h2>Conclusion</h2>\n<p>Axios is one of the most popular HTTP clients available out there, equipped with great useful features. Axios is also great with libraries like React and for doing HTTP calls from backend with Node js. In this tutorial, we have seen just the major features of Axios js with examples. If you are interested for more info about the client, you can check the official <a href=\"https://github.com/axios/axios\"><em>Axios Github Page</em></a>, or <a href=\"https://www.npmjs.com/package/axios\"><em>Axios NPM</em></a> page for more info and documentation.</p>","frontmatter":{"path":"/axios-http-client/","date":"2019-11-02T17:15:49.619Z","title":"Guide to Axios js Http Client","author":"Aleksandar Vasilevski","image":"/assets/cover/web-cables.jpg","category":"JavaScript","tags":"#axios #http #javascript #npm","featured":false}}},{"node":{"id":"64e24019-4401-5be7-8690-74f26b73c30a","html":"<p><img src=\"/assets/css.jpg\" alt=\"css-logo\"></p>\n<h2>What is a Media Query</h2>\n<p>Responsive web design is a very important topic for web developers as every year there are more and more users using smartphones and tablets. To have a responsive web site, it is important to be \"Design for Mobile First\". Mobile-first means designing for mobile before designing for other devices like desktop, tablet, etc. For that purpose, it is important to know what it is and how to use media queries.\nMedia Query is a CSS feature introduced in CSS3, which allows us to specify when certain CSS rules should be used. With media queries, we can easily apply unique CSS rules to specific devices like Laptop, Tablet, Mobile, etc. Media queries are used for the following:</p>\n<p><ad-incontent></ad-incontent></p>\n<ul>\n<li>To conditionally apply styles with the CSS @media and @import</li>\n<li>To target specific media for the <style>, <link>, <source>, and other HTML elements with the media= attribute.</li>\n<li>To test and monitor media states using the Window.matchMedia() and MediaQueryList.addListener() JavaScript methods.</li>\n</ul>\n<h2>How to make a Media Query</h2>\n<p>To make a media query we can use an optional <strong>media type</strong> and any number of <strong>media feature</strong> expressions. A media query is true if the media type matches the device on which a document is being displayed.</p>\n<p><strong>Media types</strong> describe the category of the device, except when <code>not</code> or <code>only</code> logical operators are used, the media type is optional and the <code>all</code> type will be used.</p>\n<ul>\n<li><code>all</code> - suitable for all devices.</li>\n<li><code>print</code> - suitable for paged material and documents viewed on a screen in print preview mode.</li>\n<li><code>screen</code> - used primarily for screens.</li>\n<li><code>speech</code> - used for speech synthesizers.</li>\n</ul>\n<p><strong>Media features</strong> describe specific characteristics of the user agent, output device, or environment. Media feature expressions test for their presence or value and are optional. Every media feature expression must be surrounded by parentheses. You can find all of the media features in the <em><a href=\"https://developer.mozilla.org/en-US/docs/Web/CSS/Media_Queries/Using_media_queries\">Documentation</a></em></p>\n<p><strong>Logical operators</strong> <code>not</code>, <code>and</code> and <code>only</code> are available to be used for a writing complex media query.</p>\n<p>To make a media query we need to use the keyword <code>@media</code> and declare the breakpoint (screen size), and set the CSS rules inside the <code>{}</code>.\nLet's see how simple media query looks like:</p>\n<p><ad-incontent></ad-incontent></p>\n<pre><code class=\"language-css\">@media only screen and (max-width: 600px) {\n  body {\n    background-color: blue;\n  }\n}\n</code></pre>\n<p>In our example above we make a media query for screens with a maximum width of 600px so if the browser window is 600px or smaller, set the background color to blue. We can also use an external stylesheet for media queries, the syntax looks like this:</p>\n<pre><code class=\"language-css\">&#x3C;link rel='stylesheet' media='screen and (max-width: 600px)' href='css/small.css' />\n</code></pre>\n<blockquote>\n<p>Note: Media queries are case sensitive.</p>\n</blockquote>\n<h2>Creating complex media queries</h2>\n<p>In some situations, we might need to create a media query that depends on multiple conditions. This is where we are going to use the logical operators: not, and, and only. Even more, you can combine multiple media queries into a comma-separated list; this will allow you to apply the same styles in different situations.</p>\n<pre><code class=\"language-css\">@media (min-width: 100px) and (orientation: landscape) { ... }\n</code></pre>\n<p>In the example above we are using the <code>and</code> logical operator to restrict styles to landscape-oriented devices with a width of at least 100 px.\nYou can limit the styles to devices with a screen, and chain the media features to the screen media type:</p>\n<pre><code class=\"language-css\">@media screen and (min-width: 100px) and (orientation: landscape) { ... }\n</code></pre>\n<h2>Device Breakpoints</h2>\n<p>There are a lot of screens and devices with different widths and heights, so it is not possible to have exact breakpoints for every device available. To keep it simple we will use a couple of groups.</p>\n<pre><code class=\"language-css\">/* Extra small devices (phones, 600px and down) */\n@media only screen and (max-width: 600px) {}\n\n/* Small devices (portrait tablets and large phones, 600px and up) */\n@media only screen and (min-width: 600px) {}\n\n/* Medium devices (landscape tablets, 768px and up) */\n@media only screen and (min-width: 768px) {}\n\n/* Large devices (laptops/desktops, 992px and up) */\n@media only screen and (min-width: 992px) {}\n\n/* Extra large devices (large laptops and desktops, 1200px and up) */\n@media only screen and (min-width: 1200px) {}\n</code></pre>\n<p><em>Device Breakpoints Example (Source: w3school)</em></p>\n<p><ad-incontent></ad-incontent></p>\n<h2>Browser Support for Media Queries</h2>\n<p>Media queries have very good browser support for min and max widths, almost all major browsers like Chrome, Firefox, Safari, iOS Safari, Android Browser, Opera and Internet Explorer from version 9 and above are currently are supporting media queries.</p>\n<table>\n<thead>\n<tr>\n<th>Chrome</th>\n<th>Firefox</th>\n<th>Safari</th>\n<th>IE9+/Edge</th>\n<th>Opera</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<td>Yes</td>\n<td>Yes</td>\n<td>Yes</td>\n<td>Yes</td>\n<td>Yes</td>\n</tr>\n</tbody>\n</table>","frontmatter":{"path":"/css-media-queries/","date":"2019-10-29T10:45:00.619Z","title":"CSS Media Queries","author":"Aleksandar Vasilevski","image":"/assets/css.jpg","category":"CSS","tags":"#css #html","featured":false}}},{"node":{"id":"134fcd94-180a-5566-a7c2-0d37c56c80f4","html":"<p><img src=\"/assets/12-best-online-tools-for-web-developers.jpg\" alt=\"css-logo\"></p>\n<p>There are a large number of online tools out there. This article is aimed to help developers in the search to find the best tools to make everyday developing experience better. 12 web tools are listed below for new and experienced developers.</p>\n<h2><a href=\"https://stackoverflow.com/\">1. Stack Overflow</a></h2>\n<p><img src=\"/assets/other/stack-overflow.jpg\" alt=\"stack-overflow\"></p>\n<p>Stack Overflow is a question and answer web site for developers. It features questions and answers on topics in computer programming. Stack Overflow is the right hand of every professional and enthusiast software developer, with its huge community of developers it is the number one tool for solving problems and gaining knowledge. Stack Overflow is free to use, just be sure first to check if the answer is already there before you ask one or you will get some negative votes.</p>\n<h2><a href=\"https://fonts.google.com/\">2. Google Fonts</a></h2>\n<p><img src=\"/assets/other/google-fonts.jpg\" alt=\"google-fonts\"></p>\n<p>Google Fonts is all you need to find and load a font for your web site. It has a wide range of free fonts and it is very easy for use, in a couple of steps you can find your favorite font, select it, and copy it to your CSS styles.</p>\n<h2><a href=\"https://developers.google.com/web/tools/chrome-devtools\">3. Chrome Developer Tools</a></h2>\n<p><img src=\"/assets/other/google-developer-tools.jpg\" alt=\"google-developer-tools\"></p>\n<p>Chrome Developer Tools offer a wide range of tools to web developers for testing and debugging their code, from editing HTML and CSS, to writing JavaScript code in real-time. Chrome Developer Tools come as browser add-ons in web browsers, and it is not hard to get started.</p>\n<p><ad-incontent></ad-incontent></p>\n<h2><a href=\"https://https://github.com/\">4. GitHub</a></h2>\n<p><img src=\"/assets/other/github.jpg\" alt=\"github\"></p>\n<p>Every developer nightmare, when you’re working on a project feature and you mess up with your code. Say welcome to version control systems or specifically, GitHub.</p>\n<h2><a href=\"https://jsfiddle.net/\">5. JSFiddle</a></h2>\n<p><img src=\"/assets/other/jsfiddle.jpg\" alt=\"jsfiddle\"></p>\n<p>With JSFiddle you can add JavaScript alone or in combination with HTML and CSS and render the code in the output window, There is also an option to save the code or send to other people. With JSFiddle, you can inject JavaScript and CSS from other web sites and load it in jQuery. It is not hard to get started, try it.</p>\n<h2><a href=\"https://jsonlint.com/\">6. JSONLint</a></h2>\n<p><img src=\"/assets/other/jsonlint.jpg\" alt=\"jsonlint\"></p>\n<p>JSONLint is a great tool for debugging JSON, it lint flags if you’ve missed something in the syntax. JSONLint is a great tool for working with big JSON formats, and it is easy to get started.</p>\n<h2><a href=\"https://www.minifier.org/\">7. Minifier</a></h2>\n<p><img src=\"/assets/other/minifier.jpg\" alt=\"minifier\"></p>\n<p>Minifier is JavaScript and CSS code minified, with minifying we can boost up website load time. Minifier removes white space in the .js and .css files and re-format them to reduce the size.</p>\n<h2><a href=\"https://unminify.com/\">8. Unminify</a></h2>\n<p><img src=\"/assets/other/unminify.jpg\" alt=\"unminify\"></p>\n<p>Unminify is the opposite of the Minifier. With Unminify you can make a .js or .css file readable. Both tools are very easy and simple for using.</p>\n<h2><a href=\"https://www.getpostman.com\">9. Postman</a></h2>\n<p><img src=\"/assets/other/postman.jpg\" alt=\"postman\"></p>\n<p>Postman is an API testing tool, it is recommended for testing calls using Put, Get, Post, Delete. Postman is available for download or like a web app, it is not hard to get started and one of the best tools for every web developer.</p>\n<h2><a href=\"https://search.google.com/test/mobile-friendly\">10. Mobile Friendly Test</a></h2>\n<p><ad-incontent></ad-incontent></p>\n<p><img src=\"/assets/other/mobile-friendly-test.jpg\" alt=\"mobile-friendly-test\"></p>\n<p>Mobile-Friendly Test like its name says it is a mobile-friendly web site testing tool. This tool is important because Google is indexing \"mobile-first\" web sites and with increased usage on mobile devices, it becomes a must for a web site to be mobile-friendly.</p>\n<h2><a href=\"https://carbon.now.sh/\">11. Carbon</a></h2>\n<p><img src=\"/assets/other/carbon.jpg\" alt=\"carbon\"></p>\n<p>Carbon is a code screenshot maker. It renders your code in a beautiful layout with options to export the code screenshot to image formats like PNG or SVG. It is very simple for using and very helpful so the copied code will look beautiful.</p>\n<h2><a href=\"https://www.pingdom.com/\">12. Pingdom</a></h2>\n<p><img src=\"/assets/other/pingdom.jpg\" alt=\"pingdom\"></p>\n<p>One of the most important thing on a website is to be fast, with Pingdom you can test a website and get excellent statistics about your website speed. It can even grade you against Google Page Speed and ranks against other websites. </p>","frontmatter":{"path":"/12-best-online-tools-for-web-developers/","date":"2019-10-27T19:30:49.619Z","title":"12 Best Online Tools for Web Developers","author":"Aleksandar Vasilevski","image":"/assets/12-best-online-tools-for-web-developers.jpg","category":"Tools","tags":"#tools #resources","featured":false}}},{"node":{"id":"fee82539-ce21-5e5e-8592-d2715d75087b","html":"<p><img src=\"/assets/java-script-101-logo.png\" alt=\"javascript-logo\"></p>\n<p>This article is part of the JavaScript 101 series, you can find the previous part on the following link: <a href=\"https://www.codespot.org/javascript-101-es6-and-beyond/\" style=\"font-weight:bold; text-transform:uppercase; color:#ff7a59;\">JavaScript 101: ES6 and Beyond</a>.</p>\n<h2>What is design pattern</h2>\n<p>In software development, a design pattern is a reusable solution for common problems in software design. Design patterns represent the best practices used by the software developers. We can think of design pattern like a programming template.</p>\n<p><ad-incontent></ad-incontent></p>\n<h2>Why should we use design patterns</h2>\n<p>Every developer wants to write clean, maintainable, readable, and reusable code. Code structuring becomes more and more important as applications become larger. The concept of design patterns has been around in the software engineering industry since the very beginning, but they weren’t formalized.\n<a href=\"https://www.amazon.com/gp/product/0201633612/ref=as_li_tl?ie=UTF8&#x26;camp=1789&#x26;creative=9325&#x26;creativeASIN=0201633612&#x26;linkCode=as2&#x26;tag=aleksandarvas-20&#x26;linkId=b0ba1ac2b5413500923f0e7c8d900fa2\"><strong>Design Patterns: Elements of Reusable Object-Oriented Software</strong></a> also called the Gang of Four, were trying to formalize the concept of design patterns in software engineering. Today the design patterns are a very important part of software development. Here we will talk about a couple of them, most important for the JavaScript programming language, but as they are very important for every software developer, feel free to check the books linked above.</p>\n<p><a target=\"_blank\"  href=\"https://www.amazon.com/gp/product/0201633612/ref=as_li_tl?ie=UTF8&camp=1789&creative=9325&creativeASIN=0201633612&linkCode=as2&tag=aleksandarvas-20&linkId=29a49fd0c901fd2215955fce44d800ab\"><img border=\"0\" style=\"margin:auto; display:block\" src=\"//ws-na.amazon-adsystem.com/widgets/q?_encoding=UTF8&MarketPlace=US&ASIN=0201633612&ServiceVersion=20070822&ID=AsinImage&WS=1&Format=_SL250_&tag=aleksandarvas-20\" ></a><img src=\"//ir-na.amazon-adsystem.com/e/ir?t=aleksandarvas-20&l=am2&o=1&a=0201633612\" width=\"1\" height=\"1\" border=\"0\" alt=\"\" style=\"border:none !important; margin:0px !important;\" /></p>\n<!-- <iframe style=\"width:120px;height:240px;display:block\" marginwidth=\"0\" marginheight=\"0\" scrolling=\"no\" frameborder=\"0\" src=\"//ws-na.amazon-adsystem.com/widgets/q?ServiceVersion=20070822&OneJS=1&Operation=GetAdHtml&MarketPlace=US&source=ac&ref=tf_til&ad_type=product_link&tracking_id=aleksandarvas-20&marketplace=amazon&region=US&placement=0201633612&asins=0201633612&linkId=c1c7cd3b314ec2b6cc4cad67f0e4c35b&show_border=false&link_opens_in_new_window=false&price_color=333333&title_color=0066c0&bg_color=ffffff\">\n    </iframe> -->\n<h2>Module design pattern</h2>\n<p>Modules design pattern is one of the most used design patterns in JavaScript, for keeping particular modules of code independent of other components. This provides loose coupling and well-structured code. Modules in JavaScript are like classes in object-oriented languages, and one of the many advantages is encapsulation for protecting the state and behavior from outside. With the module pattern, we can set public or private access level. Before ES6, programming language JavaScript didn't have build-in modules, so developers had to use the module pattern to implement modules. With ES6 JavaScript has native modules, that are stored in js files. Here you can check more about the <a href=\"https://www.codespot.org/javascript-101-es6-and-beyond/\"><strong>ES6</strong></a>, and in the next example we will look at the ES6 module design pattern:</p>\n<pre><code class=\"language-javascript\">// math.js\nfunction add(num1, num2) {\n  console.log('Add:', num1, num2);\n  return num1 + num2;\n}\nfunction sub(num1, num2) {\n  console.log('Sub:', num1, num2);\n  return num1 - num2;\n}\nexport {add, sub};\n\n// main.js\nimport { add, sub } from './math.js';\nconsole.log(add(2, 2)); //4\nconsole.log(sub(2, 2)); //0\n</code></pre>\n<p><ad-incontent></ad-incontent></p>\n<h2>Prototype design pattern</h2>\n<p>Prototype design pattern is an object-based creational design pattern and relies on the JavaScript prototypical inheritance. The prototype model is used for creating objects. The objects created are clones of the original object. In our example, we will use a car object that we use as a prototype to create another object, and we will define one more property on the new object.</p>\n<pre><code class=\"language-javascript\">//original object\nconst car = {\n  manufacturer: 'Tesla',\n  start() {\n    return 'started';\n  },\n  stop() {\n    return 'stopped';\n  },\n};\n\n// we will be using Object.create to create the new object from the original one\n// Object.create(proto[, propertiesObject])\nconst myCar = Object.create(car, { model: { value: 'Model S' } });\nconsole.log(myCar.__proto__ === car); // true\n</code></pre>\n<p>We can see in the following diagram how to prototypal inheritance is working:</p>\n<p><img src=\"https://upload.wikimedia.org/wikipedia/commons/1/14/Prototype_UML.svg\" alt=\"javascript-prototypal-inheritance\">\n<em>UML Diagram for Prototypal Inheritance (Source: Wikipedia)</em></p>\n<h2>Observer design pattern</h2>\n<p>Observer design pattern is when one object (publisher) changes its state, all the other dependent objects (subscribers) are updated automatically. If you have used <code>addEventListener</code> or jQuery .<code>on</code> you will be familiar with the pattern. It has the most influence over Reactive Programming like <a href=\"http://reactivex.io/\"><strong>RxJS</strong></a>. Let's check how the observer pattern is working in the next example:</p>\n<pre><code class=\"language-javascript\">const Subject = function() {\n  this.observers = [];\n\n  return {\n    subscribeObserver: function(observer) {\n      this.observers.push(observer);\n    },\n    unsubscribeObserver: function(observer) {\n      let index = this.observers.indexOf(observer);\n      if(index > -1) {\n        this.observers.splice(index, 1);\n      }\n    },\n    notifyObserver: function(observer) {\n      let index = this.observers.indexOf(observer);\n      if(index > -1) {\n        this.observers[index].notify(index);\n      }\n    },\n    notifyAllObservers: function() {\n      for(let i = 0; i &#x3C; this.observers.length; i++){\n        this.observers[i].notify(i);\n      };\n    }\n  };\n};\n\nconst Observer = function() {\n  return {\n    notify: function(index) {\n      console.log(\"Observer \" + index + \" is notified!\");\n    }\n  }\n}\n\nconst subject = new Subject();\nconst observer1 = new Observer();\nconst observer2 = new Observer();\n\nsubject.subscribeObserver(observer1);\nsubject.subscribeObserver(observer2);\n\nsubject.notifyObserver(observer2); // Observer 2 is notified!\n\nsubject.notifyAllObservers();\n// Observer 1 is notified!\n// Observer 2 is notified!\n</code></pre>\n<p>And now let's check the diagram for the observer pattern.</p>\n<p><img src=\"https://miro.medium.com/max/1068/1*mmTHcQFfbad820Dz75hHgQ.png\" alt=\"javascript-observer-pattern\">\n<em>UML Diagram for Observer Pattern (Source: Wikipedia)</em></p>\n<p><ad-incontent></ad-incontent></p>\n<h2>Singleton design pattern</h2>\n<p>A Singleton is an object which can only be instantiated once. Singleton creates a new instance of a class if one not exists. If there is an instance of that class, it will return the reference of that object instead. JavaScript has singleton by default, but it is not called singleton instead it is called object literal. For example:</p>\n<pre><code class=\"language-javascript\">const car = {\n  manufacturer: 'Tesla',\n  model: 'S',\n  fuel: 'electricity',\n  start: function() {\n    console.log('started');\n  }\n}\n</code></pre>\n<p>Each object in JavaScript programming language occupies a unique memory location and when we call the car object, we are returning a reference to this object. If we try to copy the car variable into another variable and modify it, we would see both of the objects are modified because every object in JavaScript is passed by reference, not by value. So there is only a single object. Let's implement singleton with the constructor function first:</p>\n<pre><code class=\"language-javascript\">let instance = null;\nfunction Car() {\n  if(instance) {\n    return instance;\n  }\n  instance = this;\n  this.manufacturer = 'Tesla';\n  this.model = 'S';\n  \n  return instance;\n}\nconst carOne = new Car();\nconst carTwo = new Car();\nconsole.log(carOne === carTwo); // true\n</code></pre>\n<p>Let's see how we can implement singleton with the module pattern:</p>\n<pre><code class=\"language-javascript\">const singleton = (function() {\n  let instance;\n  \n  function init() {\n    return {\n      manufacturer = 'Tesla',\n      model = 'S',\n    };\n  }\n  return {\n    getInstance: function() {\n      if(!instance) {\n        instance = init();\n      }\n      \n      return instance;\n    }\n  }\n})();\nconst instanceA = singleton.getInstance();\nconst instanceB = singleton.getInstance();\nconsole.log(instanceA === instanceB); // true\n</code></pre>\n<p>Here we are creating a new instance by calling the <code>singleton.getInstance</code>, if an instance doesn't exist it will create a new instance with the <code>init()</code>, if an instance already exists, we would get that instance instead.</p>\n<p><ad-incontent></ad-incontent></p>\n<h2>Conclusion</h2>\n<p>Design patterns are a very important part of software engineering and can be very helpful in solving common problems. But this is a very broad subject, and it is simply not possible to include everything about them. I suggest you take a look at these books:</p>\n<ol>\n<li><a href=\"https://www.amazon.com/gp/product/0201633612/ref=as_li_tl?ie=UTF8&#x26;camp=1789&#x26;creative=9325&#x26;creativeASIN=0201633612&#x26;linkCode=as2&#x26;tag=aleksandarvas-20&#x26;linkId=b0ba1ac2b5413500923f0e7c8d900fa2\"><strong>Design Patterns: Elements Of Reusable Object-Oriented Software</strong> by Erich Gamma, Richard Helm, Ralph Johnson and John Vlissides (Gang of Four)</a></li>\n<li><a href=\"https://www.amazon.com/gp/product/0596806752/ref=as_li_tl?ie=UTF8&#x26;camp=1789&#x26;creative=9325&#x26;creativeASIN=0596806752&#x26;linkCode=as2&#x26;tag=aleksandarvas-20&#x26;linkId=73a1698882e1b45c2a3f2b5c2f023af4\"><strong>JavaScript Patterns</strong> by Stoyan Stefanov</a></li>\n</ol>","frontmatter":{"path":"/javascript-101-design-patterns/","date":"2019-10-24T15:15:49.619Z","title":"JavaScript 101: Design Patterns","author":"Aleksandar Vasilevski","image":"/assets/java-script-101-logo.png","category":"JavaScript","tags":"#javascript #js #designpatterns","featured":false}}},{"node":{"id":"e0648590-35ed-521b-bdfb-44f831b393d7","html":"<p><img src=\"/assets/ssl.jpg\" alt=\"css-logo\"></p>\n<p>SSL (Secure Sockets Layer) is a security protocol for establishing authenticated and encrypted links between a server and a client in a network, typically a web server and a browser, or a mail server and a mail client. With SSL we can securely transmit sensitive information like login credentials and credit card numbers. Without SSL the data transferred between the client and a server is sent in plain text, if an attacker can intercept the data between the browser and the server, they can get that information.</p>\n<p><ad-incontent></ad-incontent></p>\n<h2>How does SSL create a secure connection?</h2>\n<p>When a client attempts to access a server that is secured with SSL, the client, and the server establish a process called SSL Handshake, the process is not visible and happens very fast. There are three keys used to set up an SSL connection, public, private and session key. Everything that is encrypted with the public key can only be decrypted with the private key. Let's see how it looks:</p>\n<p><strong>Browser</strong> connects to the server, secured with SSL (https).<br>\n<strong>Server</strong> sends a copy of the SSL certificate, including the public key.<br>\n<strong>Browser</strong> checks the certificate and if it is valid it creates, encrypts, and sends back a symmetric session key using the server’s public key.<br>\n<strong>Server</strong> decrypts the symmetric session key using its private key and sends back an encrypted session key to start the encrypted session.</p>\n<h2>Why use SSL on your website?</h2>\n<p>The SSL protocol determines the encryption for both the link and the data being transmitted. Browsers can interact with secured web servers using the SSL security protocol, but to do that they need the SSL Certificate for establishing a secure connection. The most common use of SSL certificates is secure web browsing via the HTTPS protocol.</p>\n<p>Today SSL should be used on almost every web site or web application, especially if there are transmission of transactions or confidential information.\nWe can check in the browser address bar to be sure that a website we are visiting is protected with an SSL certificate, there should be a lock icon at the start. Modern browsers also alert visitors to insecure websites that do not have an SSL certificate. </p>\n<p><a href=\"//namecheap.pxf.io/c/1966975/459718/5618\" id=\"459718\"><img src=\"//a.impactradius-go.com/display-ad/5618-459718\" border=\"0\" alt=\"SSL Certificate for just $8.88 with Namecheap\" width=\"728\" height=\"90\"/></a><img height=\"0\" width=\"0\" src=\"//namecheap.pxf.io/i/1966975/459718/5618\" style=\"position:absolute;visibility:hidden;\" border=\"0\" /></p>\n<h2>Where can I get SSL Certificate?</h2>\n<p>There are a lot of services offering SSL sertificates, one of the best offers you can find is at NameCheap, you can check it on the link below.</p>\n<h3 id=\"408767\"><a href=\"//namecheap.pxf.io/c/1966975/408767/5618\">Protect your Business with an SSL certificate</a></h3>\n<img height=\"0\" width=\"0\" src=\"//namecheap.pxf.io/i/1966975/408767/5618\" style=\"position:absolute;visibility:hidden;\" border=\"0\" />","frontmatter":{"path":"/what-is-ssl/","date":"2019-10-23T00:00:30.619Z","title":"What is SSL (Secure Sockets Layer)","author":"Aleksandar Vasilevski","image":"/assets/ssl.jpg","category":"Network","tags":"#security #ssl #network","featured":false}}},{"node":{"id":"f93d3ca5-77ae-5eca-9e93-58d8111783f1","html":"<p><img src=\"/assets/css.jpg\" alt=\"css-logo\"></p>\n<h2>What is a pseudo-element?</h2>\n<p>Pseudo element allows us to create elements that are not on the DOM, with the pseudo element we can style a specific part of the element content. Pseudo elements can be created only using the CSS, and that's why they are great, we can style a website without adding extra markup.</p>\n<p><ad-incontent></ad-incontent></p>\n<h2>::before / ::after</h2>\n<p>Before and After (<code>::before</code> and <code>::after</code>) are pseudo elements that allow us to insert content into a page from CSS. The browsers will render these elements as \"generated content\" if they have set a value in the content property. The difference between <code>::before</code> and <code>::after</code> is that when before is used the content will be inserted before any other content in the HTML, and the after is the opposite. The content value can be a string <code>content: \"some text\";</code>,  image <code>content: url(/image.jpg);</code>, and an empty string <code>content: \"\";</code>.</p>\n<p>Let's see the before and after elements syntax in the next example:</p>\n<pre><code class=\"language-css\">div::before {\n  content: \"Hello, World\"\n}\n\ndiv::after {\n  content: \"Goodbye, World\"\n}\n</code></pre>\n<p>Initially, the pseudo-elements were made using just the single colon like (<code>:before</code>, <code>:after</code>), the double colon elements (<code>::before</code> and <code>::after</code>) is an updated format. Almost all major browsers (Chrome, Firefox, Edge, Opera) support <code>::before</code> and <code>::after</code> pseudo-elements, just Internet Explorer and Safari are not supporting it. In Internet Explorer, the single colon format is still used.</p>","frontmatter":{"path":"/css-before-and-after/","date":"2019-10-19T21:20:00.619Z","title":"CSS ::before and ::after","author":"Aleksandar Vasilevski","image":"/assets/css.jpg","category":"CSS","tags":"#css #html","featured":false}}},{"node":{"id":"ff115cb6-1b0b-55fa-9966-b317aab9822e","html":"<p><img src=\"/assets/java-script-101-logo.png\" alt=\"javascript-logo\"></p>\n<p>This article is part of the JavaScript 101 series, you can find the previous part on the following link: <a href=\"https://www.codespot.org/javascript-101-object-oriented-programming/\" style=\"font-weight:bold; text-transform:uppercase; color:#ff7a59;\">JavaScript 101: Object Oriented Programming</a>.</p>\n<h2>What is ECMAScript 6</h2>\n<p>ECMAScript is a scripting language specification for the JavaScript programming language, the first edition started in 1997, but here we will talk about the 6th edition or ECMAScript 2015 and beyond. In the ES6, short for ECMAScript 6 there were added significant new features, new syntax for writing a more complex and modern application, though web browsers support for ES6 is not yet complete, major browsers support some features. Let's dive into the major features of the ES6.</p>\n<p><ad-incontent></ad-incontent></p>\n<h3>Constants</h3>\n<p>Constants or <code>const</code> are values that are defined once per scope, and cannot be redefined again. They are a very good replacement for <code>var</code> in a lot of situations when we don't want to assign new value by mistake.</p>\n<pre><code class=\"language-javascript\">const value = 5   //we are defining a constant\nvalue = 2         //can not be assigned again!\n</code></pre>\n<h3>Let</h3>\n<p>The <code>let</code> are allowing us to declare a variable with block scope, variables declared retain the value till the end of the current block. The <code>const</code> is block-scoped too.</p>\n<pre><code class=\"language-javascript\">{\n  let a = 5\n  {\n    let a = 2\n    console.log('inner value is: '+ a)\n  }\n  console.log('outer value is: ' + a)\n}\n\n//Results\n'inner value is: 2'\n'outer value is: 5' \n</code></pre>\n<h3>Arrow Functions</h3>\n<p>The arrow function is a new, shorter syntax for writing functions, the <code>{}</code>,  <code>function</code> and the <code>return</code> keywords are not needed. Arrow functions doesn't have <code>this</code>, that's why they are not very good for object methods.</p>\n<pre><code class=\"language-javascript\">const add = arg => arg + 5\nadd(5); //Result is 10\n</code></pre>\n<p><ad-incontent></ad-incontent></p>\n<h3>Default Function Parameters</h3>\n<p>Function parameters now can be set with default values, when the <code>undefined</code> argument is passed, the default value will be used.</p>\n<pre><code class=\"language-javascript\">const add = (arg1, arg2 = 5) => arg1 + arg2\nadd(5, 5) //Result is 10\nadd(5)    //Result is still 10, becouse we have set a default arg of 5\n</code></pre>\n<h3>Rest Parameter</h3>\n<p>With rest function parameters we can pass in an arbitrary number of arguments in a function. Inside the function, we will get the arguments as an array.</p>\n<pre><code class=\"language-javascript\">const someFun = function(...args){\n  console.log(...args)\n}\n</code></pre>\n<h3>Spread Operator</h3>\n<p>The spread operator has the same syntax as the rest parameter, but instead, the spread operator takes an array.</p>\n<pre><code class=\"language-javascript\">const sumUp = function(a, b, c){\n  console.log(a + b + c)\n}\n\nconst myArray = [2, 2, 2]\nsumUp(...myArray) //And we got 6\n</code></pre>\n<h3>Object Destructing</h3>\n<p>Object destruction makes the assignments of the values from an object much easier than before.</p>\n<pre><code class=\"language-javascript\">const user = {\n  firstName: 'Kim',\n  lastName: 'Kardashian',\n  age: 38\n}\n\nconst{firstName, lastName, age}=user\nconsole.log(firstName + ' ' + lastName + ' ' + age)\n</code></pre>\n<p><ad-incontent></ad-incontent></p>\n<h3>Class Syntax</h3>\n<p>With ES6, JavaScript has got syntax for defining a class, under the hood it is still the protytype-based classes but it enhance code clarity. You can read more about the Object Oriented programming in the <a href=\"https://www.codespot.org/javascript-101-object-oriented-programming/\"><strong>JavaScript 101: Object Oriented Programming</strong></a>.</p>\n<pre><code class=\"language-javascript\">class User{\n  constructor(name){\n    this.name = name\n  }\n\n  becomeFamous(){\n    console.log(\"I'm famous\")\n  }\n}\n\nconst kimKardashian = new User('Kim Kardashian')\nkimKardashian.becomeFamous()  //and we got \"I'm famous\"\n</code></pre>\n<h3>Template Literals</h3>\n<p>Template literals or template strings are useful to concatenate strings.</p>\n<pre><code class=\"language-javascript\">const someFun = function(arg1, arg2){\n  return 'Hello from ${arg1}, ${arg2}'\n}\n\nsomeFun('Kim', 'Kardashian')\n</code></pre>\n<h3>Import and Export</h3>\n<p>With import and export in JavaScript, we can create separate and reusable components. We can make a module export it, and in another JavaScript module, we can import it in the previous module.</p>\n<pre><code class=\"language-javascript\">//First JavaScript module\nexport default function sum(x, y){\n  return x + y\n}\n</code></pre>\n<pre><code class=\"language-javascript\">//Second JavaScript module\nimport sum from './sumComponent'\nconsole.log(sum(2, 2))  //result is 4\n</code></pre>\n<h3>Promises and Async/Await</h3>\n<p>Promises are a new way to write asynchronous code in JavaScript, they can be used a lot in communication with an API for example, with promises we got much cleaner code than using the old way with callbacks. to learn about the Promises you can check: <a href=\"https://www.codespot.org/async-javascript-part-2-promises/\"><strong>Async JavaScript Part 2: Promises</strong></a>, and if you are comfortable with them you can go to  <a href=\"https://www.codespot.org/async-javascript-part-3-async-await/\"><strong>Async JavaScript Part 3: Async/Await</strong></a>, the ES8 upgrade over promises.</p>\n<pre><code class=\"language-javascript\">let promise = fetch('api/give-me-json');\npromise.then((response) => {\n  console.log(response)\n}).catch((error) => {\n  console.log(error)\n})\n</code></pre>\n<p><ad-incontent></ad-incontent></p>\n<h2>Conclusion</h2>\n<p>ES6 is the cutting edge update for the JavaScript programming language, with it we can write much cleaner and modern looking code, also it is the stepping stone to the modern front-end frameworks like React, Express, etc.</p>\n<p>Next part: <a href=\"https://www.codespot.org/javascript-101-design-patterns/\" style=\"font-weight:bold; text-transform:uppercase; color:#ff7a59;\">JavaScript 101: Design Patterns</a>.</p>","frontmatter":{"path":"/javascript-101-es6-and-beyond/","date":"2019-10-16T14:30:49.619Z","title":"JavaScript 101: ES6 and Beyond","author":"Aleksandar Vasilevski","image":"/assets/java-script-101-logo.png","category":"JavaScript","tags":"#javascript #javascript101 #es6","featured":false}}},{"node":{"id":"b0a79e79-e555-52bd-a3da-9993def34de5","html":"<p><img src=\"/assets/java-script-101-logo.png\" alt=\"javascript-logo\"></p>\n<p>This article is part of the JavaScript 101 series, you can find the previous part on the following link: <a href=\"https://www.codespot.org/javascript-101-scope-and-closures/\" style=\"font-weight:bold; text-transform:uppercase; color:#ff7a59;\">JavaScript 101: Scope and Closures</a>.</p>\n<h2>What is Object Oriented Programming in JavaScript</h2>\n<p>Object-Oriented Programming is a programming paradigm or a way to approach and solve a problem. The basic idea behind object-oriented programming is the ability to model real-world objects that we want to represent in our program. Every object we model can have data which is the properties (fields or state) and behavior (methods) of that particular object. There are couple major concepts behind Object-Oriented Programming in JavaScript like Encapsulation and Inheritance.</p>\n<p><ad-incontent></ad-incontent></p>\n<h2>Class and Objects</h2>\n<p>What is a class? class is a template or blueprint for creating objects, for example, we can define a class car and put properties like name, tank capacity, and horsepower, and methods for starting the car, opening windows. To instantiate new objects from a class, the class need to have a constructor too and we can instantiate (create) as many objects as we want from our class, in our case cars, so the class is like a factory for the cars and the objects are the cars itself. We will do our examples with the EcmaScript 6 syntax and the new the class keyword. Let's see a simple example in JavaScript:</p>\n<pre><code class=\"language-javascript\">class Car { \n    constructor(input_name, input_horswpower) {\n    this.name = input_name;\n    this.horsepower = input_horswpower;\n  } \n\n  turnOn(){\n    return 'The ' + this.name + ' is turned on';\n  }\n\n  setName(newName){\n    this.name = newName;\n  }\n}\n</code></pre>\n<p>In our example the function <code>Car</code> is the class (blueprint) for making new cars, every car has a name and a horsepower given with the arguments. To create an object of the car class we need to call the class and pass the required arguments, like in the following example:</p>\n<pre><code class=\"language-javascript\">var carOne = new Car('BMW', 180);\nvar carTwo = new Car('Toyota', 90);\n\ncarOne.turnOn();\ncarTwo.turnOn();\n</code></pre>\n<p>Here we are instantiating two objects of the class car both have different names and horsepower properties, and both have a method <code>turnOn()</code>. We can create classes witout arguments for the constructor too if we want to, also we can use the methods to add functionality to our objects and call them <code>carOne.turnOn();</code>. With the properties and methods, we can add as many as we want functionalities, to model real-world objects. To have better understanding of the Object-Oriented Programming we need to check some of the important concepts in JavaScript like encapsulation and inheritance.</p>\n<h3>Encapsulation</h3>\n<p>Encapsulation is an OOP concept that keeps the data from outside interference and misuse, the data encapsulation is also known as data hiding. This means we should not get the horsepower or the car name in our example like accesing simple properties in JavaScript.</p>\n<pre><code class=\"language-javascript\">carOne.name = 'Mercedes';   //Don't use it this way.\ncarOne.setName('Mercedes')  //Use this instead.\n</code></pre>\n<p>Objects, like our cars, should have exclusive control of their data (properties), we should not modify it like in the first example, instead we should use a dedicated methods (getters and setters) like in the second example.</p>\n<p><ad-incontent></ad-incontent></p>\n<h3>Inheritance</h3>\n<p>Inheritance allows us to create a new class by extending an existing class and inheriting the properties and methods from the parent class. For an example we can have a parent class <code>Car</code> and child classes like <code>Bmw</code>, <code>Toyota</code>, etc, and they will inherit the properties and the methods from the parent, so we are not needed to make every car to turn on or open windows, etc.</p>\n<p>JavaScript support for Object Oriented Programming is not on the same level as some languages like Java, but it is still getting better. Originally JavaScript was a more of a prototype-based and functional programming language, not intended for large scale applications. The Object Oriented was built on top of the original prototype based technique. There is much more about Object Oriented Programming, this is just an introduction for beginners to get an idea of the paradigm.</p>\n<p>Next part: <a href=\"https://www.codespot.org/javascript-101-es6-and-beyond/\" style=\"font-weight:bold; text-transform:uppercase; color:#ff7a59;\">JavaScript 101: ES6 and Beyond</a>.</p>","frontmatter":{"path":"/javascript-101-object-oriented-programming/","date":"2019-10-13T16:30:49.619Z","title":"JavaScript 101: Object Oriented Programming","author":"Aleksandar Vasilevski","image":"/assets/java-script-101-logo.png","category":"JavaScript","tags":"#javascript #javascript101 #oop","featured":false}}},{"node":{"id":"12e8c531-20c6-5b3e-a96c-d64298822f0c","html":"<p><img src=\"/assets/css_tricks.jpg\" alt=\"css-logo\"></p>\n<p>In this part of the series CSS Tricks, we will do custom dropdown with a button. The default bootstrap dropdown component works very well but in some rare cases we want after the selection of the dropdown for example if it is a link, not to go straight on the next page, but to have a <code>Go</code> button, in this case, we need to make custom dropdown. For that purpose, we will use the <code>select</code> HTML element and <code>option</code> HTML element, also we will need the jQuery library. Let's see how the code should look in our example:</p>\n<p><ad-incontent></ad-incontent></p>\n<p>HTML code:</p>\n<pre><code class=\"language-html\">&#x3C;div>\n  &#x3C;select id=\"customDropdown\" required>\n    &#x3C;option value=\"\" disabled selected hidden>Pick an option..&#x3C;/option>\n    &#x3C;option value=\"value-one\">Option One&#x3C;/option>\n    &#x3C;option value=\"value-one\">Option Two&#x3C;/option>\n    &#x3C;option value=\"value-one\">Option Three&#x3C;/option>\n  &#x3C;/select>\n  &#x3C;a id=\"goBtn\" class=\"btn\">GO&#x3C;/a>\n&#x3C;/div>\n</code></pre>\n<p>CSS code:</p>\n<pre><code class=\"language-css\">.dropdown{\n  text-align: center;\n  left: 0.8%;\n  top: 30%;\n  position: relative;\n}\n#customDropdown{\n  height: 50px;  \n  width: 320px;\n  padding: 0 20px;\n  border-radius: 30px;\n  border: 1.5px solid #76b520;\n  color: #76b520;\n  font-size: 20px;\n  outline: none;\n  appearance: none; \n  -webkit-appearance: none;\n  -moz-appearance: none;\n}\n#goBtn{\n  height: 50px;\n  width: 50px;\n  padding: 17px 14px;\n  border-radius: 50%;\n  background-color: #ff9700;\n  color: #fff;\n  font-weight: bold;\n  font-size: 15px;\n  position: relative;\n  right: 54px;\n  bottom: 1.25px;\n  cursor: pointer;\n}\n</code></pre>\n<p>JavaScript code:</p>\n<pre><code class=\"language-javascript\">$(\"#customDropdown\").change(function (e) {\n  var selectedValue = $('#customDropdown').val();\n\n  $(\"#goBtn\").click(function (e) {\n    $(\"#goBtn\").attr(\"href\",  \"/nextpage/\");\n  });\n});\n</code></pre>\n<p><ad-incontent></ad-incontent></p>\n<p>And when we look up in the browser the result should look like this:\n<img src=\"/assets/css-tricks/css_tricks_create_custom_dropdown_with_button_example_one.png\" alt=\"custom-css-dropdown\"></p>\n<p>We are using <code>&#x3C;div></code> as a root element, inside we have <code>&#x3C;select></code> element and an <code>&#x3C;a></code> element. In the <code>&#x3C;select></code> element we have four <code>&#x3C;option></code> element which the first one is just for the text placeholder inside our dropdown menu, and the other three are the possible options.\nThe <code>&#x3C;a></code> element is a simple link, also we are getting selected value from the dropdown inside our JavaScript code. You may need to use different values depending on the size of the dropdown.</p>","frontmatter":{"path":"/css-tricks-create-custom-dropdown-with-button/","date":"2019-10-12T14:00:00.619Z","title":"CSS Tricks: Create Custom Dropdown with Button","author":"Aleksandar Vasilevski","image":"/assets/css_tricks.jpg","category":"CSS","tags":"#css #html","featured":false}}},{"node":{"id":"8216f3b6-a450-5f3e-86c8-21e3421da7ff","html":"<p><img src=\"/assets/css_tricks.jpg\" alt=\"css-logo\"></p>\n<p>In some of the cases, the standard HTML bullets list can not be what we want, sometimes we need to use images instead of the list bullets. In this example, we will see how we can achieve it.</p>\n<p>To create the list we will use the <code>&#x3C;ul></code> element which stands for unordered list and the <code>&#x3C;li></code> elment which stands for the list item, the HTML code to create a list with list items looks like these:</p>\n<p><ad-incontent></ad-incontent></p>\n<pre><code class=\"language-html\">&#x3C;ul>\n  &#x3C;li>List Item One&#x3C;/li>\n  &#x3C;li>List Item Two&#x3C;/li>\n  &#x3C;li>List Item Three&#x3C;/li>\n&#x3C;/ul>\n</code></pre>\n<p>When we look our code in the browser we got the following result:</p>\n<p><img src=\"/assets/css-tricks/CSS_Tricks_Replacing_List_Bullets_with_Images_example_one.png\" alt=\"css-example-one\"></p>\n<p>To change the bullet to an image, we will add two new CSS classes one for the <code>&#x3C;ul></code> element the other one for the <code>&#x3C;li></code> element. For the list class, we will set the padding and the margin to \"0\" and set the list-style-type to none. In the star class, we will set the background with our star png file, set the background to no-repeat and set it to left top, after that we need to set the height and the padding-top and padding-left (You might need to use different numbers depend on image to be positioned nicely relative to the text.).</p>\n<pre><code class=\"language-css\">.list{\n  padding: 0;\n  margin: 0;\n  list-style-type: none;\n}\n.star{\n  background: url('img/star.png') no-repeat left top;\n  height: 34px;\n  padding-top: 7px;\n  padding-left: 44px;\n}\n</code></pre>\n<p>And the HTML code should look like this:</p>\n<pre><code class=\"language-html\">&#x3C;ul class=\"list\">\n  &#x3C;li class=\"star\">List Item One&#x3C;/li>\n  &#x3C;li class=\"star\">List Item Two&#x3C;/li>\n  &#x3C;li class=\"star\">List Item Three&#x3C;/li>\n&#x3C;/ul>\n</code></pre>\n<p><ad-incontent></ad-incontent></p>\n<p>And we got the following result:</p>\n<p><img src=\"/assets/css-tricks/CSS_Tricks_Replacing_List_Bullets_with_Images_example_two.png\" alt=\"css-example-two\"></p>","frontmatter":{"path":"/css-tricks-replacing-list-bullets-with-images/","date":"2019-10-11T21:00:49.619Z","title":"CSS Tricks: Replacing List Bullets with Images","author":"Aleksandar Vasilevski","image":"/assets/css_tricks.jpg","category":"CSS","tags":"#css #html","featured":false}}},{"node":{"id":"46a6c0e5-5fed-5b6a-b46d-48d17ba9019e","html":"<p><img src=\"/assets/token-vs-session.jpg\" alt=\"token-vs-session\"></p>\n<h2>HTTP (HyperText Transfer Protocol)</h2>\n<p>HTTP is a protocol for communication between the client and the server. HTTP is stateless, which means each request doesn't know of any previous actions. For example, when a user logs in, and then navigate through the app, the server will not know that we just logged in without session or token authentication. </p>\n<p><ad-incontent></ad-incontent></p>\n<h2>Session Authentication</h2>\n<p>In session authentication, the server is responsible for creating a session for the particular user when the user log's in, after that the id of the session is stored in a cookie on the user browser. For every request sent by the user, the cookie will be sent too, where the server can compare the session id from the cookie with the session information stored on the server so the user identity is verified.</p>\n<h2>Token Authentication</h2>\n<p>In token authentication, the server creates a JSON Web Token (JWT) and sends the token to the client. The JSON Web Token usually is stored in a local storage or in the cookie, and it is included in every request made by the user. The server will validate the JSON Web Token. The JSON Web Token authentication is a more modern approach used in newer web applications and for mobile devices. The user state is not stored on the server with this approach instead it is stored in the token. </p>\n<p><img src=\"/assets/cookie-token-auth.png\" alt=\"auth\"></p>\n<h2>Scalability</h2>\n<p>Generally, the JSON Web Token scales much better with the size of the application because it is stateless, there is no need user information to be stored, on the other side sessions can use a lot of the server resources if the application has a lot of traffic.</p>\n<h2>Security</h2>\n<p>The JSON Web Token usually is either stored in local storage or cookies, and JavaScript has the access to the storage, this simply means that JSON Web Tokens might be vulnerable to XSS (Cross-site Scripting), that's why very sensitive data should not be stored in the Local Storage. I case when the JSON Web Tokens are stored in the cookies are vulnerable to CSRF (Cross-site Request Forgery) attacks. One way to prevent the CRSF attack is to be sure that the cookie is accessible by only your domain. The JWT also should be with short expiration times and HTTPS/SSL should be used for safe client and server transmission.</p>\n<p><ad-incontent></ad-incontent></p>\n<h2>Which Is Better?</h2>\n<p>While sessions and JSON Web Tokens are both viable options, in some situations one is better to be used over the other. For smaller and medium websites, when we got just user login session authentication is usually good. For larger web sites and applications, when we need to handle a lot of requests, JSON Web Token is much better because of scaling.</p>","frontmatter":{"path":"/token-vs-session-authentication/","date":"2019-10-06T22:30:49.619Z","title":"Token vs Session Authentication","author":"Aleksandar Vasilevski","image":"/assets/token-vs-session.jpg","category":"Network","tags":"#token #session #auth #security #network","featured":false}}},{"node":{"id":"d0ad7761-6121-509d-9b89-07edbb641297","html":"<p><img src=\"/assets/java-script-101-logo.png\" alt=\"javascript-logo\"></p>\n<p>This article is part of the JavaScript 101 series, you can find the previous part on the following link: <a href=\"https://www.codespot.org/javascript-101-functions/\" style=\"font-weight:bold; text-transform:uppercase; color:#ff7a59;\">JavaScript 101: Functions</a>.</p>\n<h2>Scope in JavaScript</h2>\n<p>In programming, the scope refers to the visibility of variables and methods from one part on the computer program to another part. In JavaScript programming language there are two types of scopes, global scope and local scope.</p>\n<p><ad-incontent></ad-incontent></p>\n<p><strong>Global Scope</strong> is the JavaScript document itself or in other words, when we are outside of functions. We can access or call variables from the global scope inside of our functions. Global scope exists as long as your application is running.</p>\n<p><strong>Local Scope</strong> is the scope inside a function itself or when a variable is defined inside a function. This means that we can't access or call these variables from outside of the same function or from the JavaScript document itself. Local scope exists as long as your functions are called and executed.</p>\n<p>What about <strong>block statements</strong> like <code>if</code> and <code>switch</code> conditions or <code>for</code> and <code>while</code> loops? unlike functions, block statements don't create a new scope, everything that was defined inside of a block statement will inherit the scope they are. With the introduction of ECMAScript 6 we can use <code>let</code> and <code>const</code> keywords instead of <code>var</code> for declaring variables, which are block-scoped and cannot be accessed or called from outside a block scope.</p>\n<h2>Closures</h2>\n<p>In JavaScript closure is the combination of functions, a closure gives you access to the outer scope from an inner function.  Let's see a simple closure example in JavaScript.</p>\n<pre><code class=\"language-javascript\">function nameFunc() {\n  var name = 'MyName';\n  function displayName() {\n    alert(name);\n  }\n  return displayName;\n}\n\nvar myFunc = nameFunc();\nmyFunc();\n</code></pre>\n<p>First we are calling <code>myFunc</code> which has the <code>nameFunc()</code> inside with the local variable <code>name</code>, and function <code>displayName()</code> as inner function. The <code>displayName()</code> has no local variables but has access to its outer function and the variable <code>name</code> The <code>displayName()</code> is returned from the outer function before executed.  When we run the above code the alert will be displayed with the <code>name</code> variable.</p>\n<p>Next part: <a href=\"https://www.codespot.org/javascript-101-object-oriented-programming/\" style=\"font-weight:bold; text-transform:uppercase; color:#ff7a59;\">JavaScript 101: Object Oriented Programming</a>.</p>","frontmatter":{"path":"/javascript-101-scope-and-closures/","date":"2019-10-04T19:00:00.619Z","title":"JavaScript 101: Scope and Closures","author":"Aleksandar Vasilevski","image":"/assets/java-script-101-logo.png","category":"JavaScript","tags":"#javascript #javascript101","featured":false}}},{"node":{"id":"bc343747-b201-5b63-80af-460150e02139","html":"<p><img src=\"/assets/nodejs-cover.png\" alt=\"javascript-logo\"></p>\n<h2>What is a Password Hashing</h2>\n<p>For every web developer, one of the most important jobs is the user data to be safe and secure from the outside world. Important user data like passwords should not be kept raw in the database, and the best way to protect the passwords is to use <strong>salted password hashing</strong>.</p>\n<p>To hash a password we must be using hash algorithms, that are one-way functions. They convert any amount of data into a fixed-length \"fingerprint\" that is not possible to be reversed. This is great for securing passwords because we can store the password in a form that is not usable if stolen, but we also need to be able to verify that the password is correct.</p>\n<p><ad-incontent></ad-incontent></p>\n<h2>How to Hash a Password in Node.js</h2>\n<p>For us to be able to use password hashing in Node.js, firstly we need to install a NPM package called <a href=\"https://www.npmjs.com/package/bcrypt\"><em>bcrypt</em></a>, with the <code>npm i bcrypt</code> command. After the package is installed we need to setup the hashing and salting structure.</p>\n<p>Structure example:</p>\n<pre><code class=\"language-javascript\">const bcrypt = require('bcrypt');               //Importing the NPM bcrypt package.\nconst saltRounds = 10;                          //We are setting salt rounds, higher is safer.\nconst myPlaintextPassword = 's0/\\/\\P4$$w0rD';   //Unprotected password\n\n\n/* Here we are getting the hashed password from the callback,\nwe can save that hash in the database */\nbcrypt.hash(myPlaintextPassword, saltRounds, (err, hash) => {\n  //save the hash in the db\n});\n\n/* Here we can compare the hashed password after we get it from\nthe database with the plaintext password */\nbcrypt.compare(myPlaintextPassword, hash, function(error, response) {\n    // response == true if they match\n    // response == false if password is wrong\n});\n</code></pre>\n<p><ad-incontent></ad-incontent></p>\n<p>The first function <code>hash()</code> is for hashing the plain text password, we have myPlaintextPassword as our first parameter which is our password as the user input it, second param is the salt rounds which is the number of rounds we are doing to secure the password(higher is better but can take a lot of time, 10 is recommended as default). In the callback, we can get an error if there is some error or hash which is our hashed password, ready to be stored in the database.</p>\n<p>The second function <code>compare()</code> is used to check the user entered password with the hashed password (like when the user is trying to log in). We have myPlaintextPassword as the first parameter which is like before the password from the user, and the second parameter is the hashed password which we should get it from the database before. If myPlaintextPassword(it is hashed too) matches the hashed password from our database the response we get will be equal to true, else the response will be false, and then we can inform the user if the password is correct or not.</p>\n<p><ad-incontent></ad-incontent></p>\n<p><img src=\"/assets/password-hashing.jpg\" alt=\"password-hashing\"></p>\n<p>Password hashing is a very important security technique when storing passwords in the database, as developers we must protect and keep the data secured.</p>","frontmatter":{"path":"/hashing-passwords-in-nodejs/","date":"2019-10-03T14:00:49.619Z","title":"Hashing Passwords in Node js","author":"Aleksandar Vasilevski","image":"/assets/nodejs-cover.png","category":"Nodejs","tags":"#nodejs #expressjs #javascript #hashpassword","featured":false}}},{"node":{"id":"16b341bb-cbf4-5841-913f-097b568a6ae5","html":"<p><img src=\"/assets/nodejs-cover.png\" alt=\"javascript-logo\"></p>\n<h2>What is a JSON Web Token or JWT?</h2>\n<p>JSON Web Token or JWT is a JSON based access token for securely transmitting information between two or more parties. The information in the JSON Web Token can be verified and trusted because it is digitally signed. Every JSON Web Token can be signed with public or private key. Generally, a server will generate and sign a token and provide that to a client, for example, the client could use that token to prove that is it logged in, and both client and the server can verify the legitimacy of the token. Every JWT has three parts: header, payload, and signature. Most of the time the JSON Web Token is used for authentication but it can be used for secure information exchange too. </p>\n<p><ad-incontent></ad-incontent></p>\n<p>JWT structure example:</p>\n<pre><code class=\"language-javascript\">Header:\n{\n  \"alg\": \"HS256\",\n  \"typ\": \"JWT\"\n}\nPayload:\n{\n  \"name\": \"John Doe\",\n  \"admin\": true\n}\nSignature:\nHMACSHA256(\n  base64UrlEncode(header) + \".\" +\n  base64UrlEncode(payload),\n  secret)\n</code></pre>\n<p>The header contains the information about the algorithm used for the encryption of the JWT, the payload is the data included in the JWT and the signature encrypted string, and it is not readable because it is encrypted with the secret key.</p>\n<h2>Signin of the JSON Web Token</h2>\n<p>To use JWT or JSON Web Token in your Node js app, you need to install an NPM package with the command <code>npm i jsonwebtoken</code> in your node js project, and after the installation you will need to import the package and generate the JSON Web Token.</p>\n<p>Let's see an example of signin the jwt:</p>\n<pre><code class=\"language-javascript\">var jwt = require('jsonwebtoken');  //Importing the jwt npm package\n\n//Asynchronously singing (creating) a Json Web Token\njwt.sign({ data: 'foobar', exp: Math.floor(Date.now() / 1000) + (60 * 60),}, privateKey, { algorithm: 'RS256' }, (err, token) => {\n  console.log(token);\n});\n</code></pre>\n<p>In the previous example we are calling <code>sing()</code> on the JWT object, and we are passing the data as the first parameter, the second parameter is the token expiration time, in our case it is one hour, after that we are passing the private key, which can be something we will keep away from others, and the last one is the algorithm. After that we will recive the token from the callback and we can send the token to the client (front-end app).</p>\n<h2>Verifying the JSON Web Token</h2>\n<p>When we receive the request from the client (front-end app) we need to verify the JWT that was signed by our back-end.</p>\n<p>Let's see an example of verifying the jwt:</p>\n<pre><code class=\"language-javascript\">//Asynchronously verifying a Json Web Token\njwt.verify(token, privateKey, (err, decoded) => {\n  console.log(decoded.foo) // bar\n});\n</code></pre>\n<p>In our example, we are calling <code>verify()</code> on the jwt object, and we are passing the received token from the client (front-end) as our first parameter, the second parameter is the private key that we have entered in our sign-in on the token. There is also a synchronous way to sign and verify JSON Web Token and much more in the documentation of the NPM <a href=\"https://www.npmjs.com/package/jsonwebtoken\"><em>package</em></a>. It is also possible of throwing errors durning the token verification process.</p>\n<p>Error object can look like these:</p>\n<pre><code class=\"language-javascript\">err = {\n  name: 'TokenExpiredError',\n  message: 'jwt expired',\n  expiredAt: 1408620000\n}\n</code></pre>\n<p><ad-incontent></ad-incontent></p>\n<p>Using JWT for securing and authenticating Rest API is the most recommended way, it is beneficial because the token can be consumed (used) by almost every front-end app including web browsers and mobile apps, and it is much more secure than the older way of using sessions. You can practice with generating and verifying the concept of JSON Web Tokens on the <a href=\"https://jwt.io/\"><em>jwt.io</em></a>.</p>","frontmatter":{"path":"/how-to-secure-nodejs-rest-api-with-jwt/","date":"2019-09-30T11:15:49.619Z","title":"How to Secure Node js Rest API with JWT","author":"Aleksandar Vasilevski","image":"/assets/nodejs-cover.png","category":"Nodejs","tags":"#nodejs #expressjs #javascript #jsonwebtoken #jwt","featured":false}}},{"node":{"id":"c2b9122d-4214-5748-b12a-1d205b6dc7e6","html":"<p><img src=\"/assets/es6-async-await.jpg\" alt=\"&#x27;es6-promises&#x27;\"></p>\n<p>This article is part of the Async JavaScript series, you can find the previous part on the following link: <a href=\"https://www.codespot.org/async-javascript-part-2-promises/\" style=\"font-weight:bold; text-transform:uppercase; color:#ff7a59;\">Async JavaScript Part 2: Promises</a>.</p>\n<h2>What is Async and Await?</h2>\n<p>Async and Await are extensions of Promises, If you are not familiar with Promises you can check the last part <a href=\"https://www.codespot.org/async-javascript-part-2-promises/\"><em>Async JavaScript Part 2: Promises</em></a>. Async/Await functions, were added with ES2017 (ES8) allowing us to write synchronous looking code while performing asynchronous operations.</p>\n<p><strong>Async</strong> functions are executed asynchronously via the event-loop and doesn't block the threat. Async functions are always going to return a value. To make a function asynchronous you need to write the keyword <code>async</code> before <code>function</code>.</p>\n<p><strong>Await</strong> keyword can be used inside an async function only and is waiting for a Promise to return as a result. await operator blocks only the async function while waiting, not the whole app.</p>\n<p><strong>Let's see a simple example</strong></p>\n<pre><code class=\"language-javascript\">async function myAsyncFunc(){\n  let result = await fetch('api/give-me-json');\n}\n</code></pre>\n<p>Here we have async function, inside we are fetching a JSON from and API, and we are telling to wait for the result. But what about error handling, what if there was some kind of error, maybe the server is down or the URL doesn't exist. We can do error handling with adding try and catch block. Let's see in our news example below.</p>\n<pre><code class=\"language-javascript\">async function myAsyncFunc(){\n  try{\n    let result = await fetch('api/give-me-json');\n    return result //If everything was ok we can return the result.\n  }catch(error){\n    return error //if something goes wrong, here we can catch the error.\n  }\n}\n</code></pre>\n<p><ad-incontent></ad-incontent></p>\n<p>Let's see how they work together with synchronous function in the event-loop.</p>\n<pre><code class=\"language-javascript\">async function asyncFun(){\n  const doWorkPromise = new Promise((resolve, reject) => {\n    setTimeout(() => {\n      resolve(\"hello from async function\")\n    }, 1000)\n  });\n  let result = await doWorkPromise;\n  console.log(result)\n}\n\nfunction secondFun(){\n  console.log(\"hello from sync function\")\n}\n\nasyncFun()\nsyncFun()\n</code></pre>\n<p>And the result is:</p>\n<pre><code class=\"language-javascript\">'hello from sync function'\n'hello from async function'\n</code></pre>\n<p>We see how the async function doesn't block the other functions in our app, <code>asyncFun()</code> was called first but executed second. Async and Await extensions were one of the best updates to the JavaScript programming language, now with Async and Await we can write much cleaner and better code.</p>","frontmatter":{"path":"/async-javascript-part-3-async-await/","date":"2019-09-28T12:20:49.619Z","title":"Async JavaScript Part 3: Async/Await","author":"Aleksandar Vasilevski","image":"/assets/es6-async-await.jpg","category":"JavaScript","tags":"#javascript #async #es8","featured":false}}},{"node":{"id":"231b9729-e8c7-5e4c-87a6-6c5a3a7cc85d","html":"<p><img src=\"/assets/jam-cover.png\" alt=\"javascript-logo\"></p>\n<p>JAM stack is a concept not a library, it is not about specific technologies to be used, instead, the JAM stack offers a new modern way of building websites and apps, that in general are better with higher security, have better performance, cost less, and offer great developing experience. In JAM stack <strong>J</strong> stands for JavaScript, <strong>A</strong> stands for APIs, and <strong>M</strong> stands for Markup. JAMstack was created by Netlify in 2018.</p>\n<p><ad-incontent></ad-incontent></p>\n<p><strong>JavaScript</strong>: Running entirely on the client-side, any dynamic programming during the request/response cycle is handled by JavaScript. This could be any frontend framework or library like React, Angular, Vue, or even vanilla JavaScript.</p>\n<p><strong>APIs</strong>: All server-side database actions or functions are abstracted into reusable APIs, accessed over HTTPS with JavaScript.</p>\n<p><strong>Markup</strong>: Templated markup should be built at deployment, usually using a site generator for content sites, or a build tool for web apps like Gatsby.js or Webpack.</p>\n<h2>Advantages of JAMstack</h2>\n<p><strong>Better Performance</strong>, pages are generated at deploy time instead of traditional build on the fly.</p>\n<p><strong>Higher Security</strong>, with server-side processes abstracted into microservice APIs, surface areas for attacks are greatly reduced.</p>\n<p><strong>Cheaper and Easier Scaling</strong>, static content can be placed on a CDN making it very easy to dynamically scale it.</p>\n<p><strong>Better Development Experience</strong>, Loose coupling and separation of controls allow for better development and debugging.</p>\n<h2>JAMstack vs Traditional</h2>\n<p>In traditional workflow, building and hosting are coupled. When a user request a page, the page is procesed and served with a long series of interaction between the back-end and the database. With the JAMstack building and hosting are decoupled, when a user request a page, the page is already build and it is directly served from the CDN. Updates to the traditional way are with platforms like WordPress or Drupal, the JAMstack content updates are through Git or a static site CMS.</p>\n<h2>Conclusion</h2>\n<p>JAMstack is becoming more and more popular day by day in the dev community, to get started with developing for JAMstack you will need JavaScript skills, it is front-end development after all. For more information, resources and best practices you can visit <em><a href=\"https://jamstack.org/\">jamstack.org</a></em></p>","frontmatter":{"path":"/what-is-the-jam-stack/","date":"2019-09-26T10:30:49.619Z","title":"What is the JAM Stack","author":"Aleksandar Vasilevski","image":"/assets/jam-cover.png","category":"JavaScript","tags":"#jamstack","featured":false}}},{"node":{"id":"05b0e160-8118-59de-ab93-353f126cea64","html":"<p><img src=\"/assets/nodejs-cover.png\" alt=\"javascript-logo\"></p>\n<p>In the latest couple of years, Node.js has become one of the must-know technologies for every web developer and programmer out there, using Node.js with Express.js framework has brought another level in building fast RESTful API's, because of scalability, speed, and simplicity.</p>\n<p>In this example. we are gonna build restful API with node.js and express.js web framework for CRUD (create, read, update, delete) operations. Before we start we need to have node.js installed on the working machine, you can find info on the official <em><a href=\"https://nodejs.org/en/download/\">documentation</a></em> on how to install node.js, if you have node.js installed you can skip this step.</p>\n<p><ad-incontent></ad-incontent></p>\n<p>To get started first we need to create a new folder, we will call it <em>node-rest-api</em>, that will contain our node.js application, after we need to navigate to inside the folder (because I am using Windows I will use GitBash, if you are using Mac or Linux, you can use terminal with relevant commands, but I will use the word \"terminal\" so don't get confused).</p>\n<p>Firstly inside the terminal, we need to run the <code>npm init</code> command, after a very short time we will be asked to insert a couple of parameters, and we will leave everything default. Now we can open the root folder <em>node-rest-api</em> with text editor by choice. Inside the root folder, we can find the package.json file, that was created automatically with the <code>npm init</code> command. Inside the <code>package.json</code> file we can find the parameters that we confirmed in the last step.</p>\n<p><strong>package.json:</strong></p>\n<pre><code class=\"language-javascript\">{\n  \"name\": \"rest-api\",\n  \"version\": \"1.0.0\",\n  \"description\": \"\",\n  \"main\": \"index.js\",\n  \"scripts\": {\n    \"test\": \"echo \\\"Error: no test specified\\\" &#x26;&#x26; exit 1\"\n  },\n  \"author\": \"\",\n  \"license\": \"ISC\"\n}\n</code></pre>\n<p>In the next step, we will open the terminal again and install the <em><a href=\"https://expressjs.com/\">Express.js</a></em>. web framework with the command <code>npm i express</code>, and what exactly is express?</p>\n<p>Express is a minimal and flexible Node.js web application framework that provides a robust set of features for web and mobile applications. With the package installed we will add new file in the root folder with a name <code>server.js</code>. Here we will set up all the code to start our node.js server, like in the next code example.</p>\n<p><ad-incontent></ad-incontent></p>\n<p><strong>server.js:</strong></p>\n<pre><code class=\"language-javascript\">const http = require('http');\nconst app = require('./app.js');\nconst port = process.env.PORT || 3000;\nconst server = http.createServer(app);\nserver.listen(port, () => {\n    console.log('Server listening on port ' + port);\n});\n</code></pre>\n<p>Firstly we are importing the 'http' package, this package provides us with functionality to start up the server, after we are importing the app module which we will create it in the moment, next we are setting the port to the .env file (still doesn't exist we will create it later), or in case is not here we are using port 3000, after we are creating a server constant and with the http package we are calling <code>createServer()</code> and we will pass the app constant which we imported moments ago. And lastly, we are calling the server to listen on the port.</p>\n<p><strong>app.js:</strong></p>\n<pre><code class=\"language-javascript\">const express = require('express');\nconst app = express();\n\napp.use((req, res, next) => {\n    res.status(200).json({\n        message: 'It is on!'\n    });\n});\n\nmodule.exports = app;\n</code></pre>\n<p>In the <code>app.js</code> file we are importing 'express' package, in the next line, we are creating a new constant app, and executing express on it. Lastly, we are calling a method <code>use()</code> on the app constant, and we need to pass to it an arrow function where we have request, response and next (req and res with short names). Inside we are sending a response with <code>res</code> and setting the status code to 200 for successful and then the JSON method, to sent back a JSON response with the message 'It is on!'. On the last line, we are exporting the app module. </p>\n<p>We can now run <code>node server.js</code> in the terminal, and we will keep the process running. To see the results we will open our favorite browser and we will go to localhost:3000 and we get the message: 'It is on!'. There is a useful tool for sending requests to the server is called <em><a href=\"https://www.getpostman.com/\">Postman</a></em> and I highly recommend it to you to use it.</p>\n<p><ad-incontent></ad-incontent></p>\n<h2>Adding Routes</h2>\n<p>Now that we have very basic restful API working, we need to add more endpoints to the API. First, we are gonna make a new folder and name it routes, inside the routes folder we will make a new file called <code>posts.js</code>, and we will add CRUD operations (create, read, update and delete).\n<strong>posts.js</strong></p>\n<pre><code class=\"language-javascript\">const express = require('express');\nconst router = express.Router();\n\nrouter.get('/', (req, res, next) => {\n    res.status(200).json({\n        message: 'Returning all posts'\n    });\n});\n\nrouter.get('/:postId', (req, res, next)=>{\n    res.status(200).json({\n        message: 'Return post with ID: ' + req.params.postId\n    });\n});\n\nrouter.post('/', (req, res, next) => {\n    res.status(200).json({\n        message: 'Added post'\n    });\n});\n\nrouter.put('/:postId', (req, res, next)=>{\n    res.status(200).json({\n        message: 'Updated post with ID: ' + req.params.postId\n    });\n});\n\nrouter.delete('/:postId', (req, res, next)=>{\n    res.status(200).json({\n        message: 'Deleted post with ID: ' + req.params.postId\n    });\n});\n\nmodule.exports = router;\n</code></pre>\n<p>The first endpoint is for GET requests which returns all the posts, second is also GET request but returns a single post by ID, the ID is sent through params. Third is a POST request, which is adding a new post, next is the PUT request, for updating posts, and the last one is DELETE request.\nAfter we have added our first router module we need to update the <code>app.js</code> to use the new router module, like in the next example:</p>\n<p><strong>Updated app.js</strong></p>\n<pre><code class=\"language-javascript\">const express = require('express');\nconst app = express();\n\nconst postRoutes = require('./routes/posts');\n\napp.use('/posts', postRoutes);\n\nmodule.exports = app;\n</code></pre>\n<p>Now we have a simple CRUD restful API built with node.js and express.js. To make use of it, it is needed to be connected to the database.</p>\n<p><ad-incontent></ad-incontent></p>\n<h2>Logining and Error Handling</h2>\n<p>Logging is important so we can see our incoming requests to the rest API. We will use the Morgan NPM package for logging. Before we can use it we need to run <code>npm i morgan</code> in the terminal, you can find more info about Morgan <em><a href=\"https://www.npmjs.com/package/morgan\">here</a></em>. To add Morgan in our project we need to add the following code in our <code>app.js</code>:</p>\n<pre><code class=\"language-javascript\">const morgan = require('morgan'); //Importing the package\napp.use(morgan('dev')); //Using the package, dev is the format.\n</code></pre>\n<p>We are now also not handling errors. If we send some invalid request we are getting a default page, but we want to send JSON response instead. To catch all error request we need to do the error handling after we are using the requests in <code>app.js</code></p>\n<pre><code class=\"language-javascript\">app.use('/posts', postRoutes); //Here we are already using the router.\n//We need to do the error handling below the routes.\n//Here we handle the errors for the requests.\napp.use((req, res, next) => {\n    const error = new Error('Not Found');   //We are creating new error object, with not found.\n    error.status = 404; //Here we are setting the error status code to 404.\n    next(error);    //Here we are executing the next callback, to forward the error request, and passing the error.\n});\n\n//Here we will handle all kinds of errors.\napp.use((error, req, res, next) => {\n    res.status(error.status || 500);    //Here we are setting the status code from the error or 500.\n    res.json({\n        error: {\n            message: error.message  //Here we are returning JSON data with a message.\n        }\n    })\n});\n</code></pre>\n<p>And here is the final look of <code>app.js</code> file:</p>\n<pre><code class=\"language-javascript\">const express = require('express');\nconst morgan = require('morgan');\nconst app = express();\nconst postRoutes = require('./routes/posts');\n\napp.use(morgan('dev'));\napp.use('/posts', postRoutes);\n\napp.use((req, res, nexr) => {\n    const error = new Error('Not Found');\n    error.status = 404;\n    next(error);\n});\n\napp.use((error, req, res, next) => {\n    res.status(error.status || 500);\n    res.json({\n        error: {\n            message: error.message\n        }\n    })\n});\n\nmodule.exports = app;\n</code></pre>\n<p><ad-incontent></ad-incontent></p>\n<p>And lastly, we will look at <strong>CORS</strong> errors, firstly what is CORS? CORS stands for Cross-Origin Resource Sharing and it is a security concept. We have a client and the server and if both coming from the same server (like localhost), then this will be successful. But if the client and the server are both on different servers (like rest API's in production) then it will be not successful. But for rest API's we need to allow the access because the concept behind rest API's is to be consumed by other clients on other servers. We can send some headers to disable the protection from the server to the client and allow access. How do these headers look, let's see in the next example:</p>\n<pre><code class=\"language-javascript\">app.use((req, res, next) => {\n    res.header('Access-Contol-Allow-Origin', '*');  //here we are allowing the access to any origin with the * symbol.\n    res.header('Access-Contol-Allow-Headers',\n     'Origin, X-Requested-With, Content-Type, Accept, Authorization');  //here we are defining which kind of headers we want to accept.\n     if(req.method === 'OPTIONS'){\n         res.header('Access-Control-Allow-Methods', 'GET, POST, PUT, PATCH, DELETE'); //we are telling the client what methods can be used.\n         return res.status(200).json({});\n     }\n     next();\n});\n//ABOVE ROUTES\n</code></pre>\n<h2>Parsing the Body</h2>\n<p>For parsing the body of the requests we will need to install a new NPM package: <em><a href=\"https://www.npmjs.com/package/body-parser\">body-parser</a></em>. To install the package we simply need to use npm i body-parser in terminal, and to use it we need to import the package at the top of our <code>app.js</code> file. And we will use it just below the last middleware we added morgan:</p>\n<pre><code class=\"language-javascript\">const bodyParser = require('body-parser');\n\napp.use(morgan('dev'));\napp.use(bodyParser.urlencoded({extended: false})); // parse application/x-www-form-urlencoded\napp.use(bodyParser.json()); // parse application/json\n</code></pre>\n<p>Now with body-parser when we create a new post object we can get the data from the incoming request, let's update the post request in the next example.</p>\n<p><strong>Post endpoint from posts.js</strong></p>\n<pre><code class=\"language-javascript\">router.post('/', (req, res, next) => {\n    const post = {\n        title: req.body.title,  //here we are setting the title from the request body.\n        body: req.body.body //here we are setting the text body from the request body.\n    }\n    res.status(200).json({\n        message: 'New post created',\n        createdPost: post   //here we will pass the created post to the response.\n    });\n});\n</code></pre>\n<p><ad-incontent></ad-incontent></p>\n<h2>Adding MongoDB with Mongoose</h2>\n<p>Finnaly we can add a database to the rest API, we are gonna use one of the most popular NoSql databases Mongo DB. Mongo DB uses JSON like documents with schema.\tTo start using MongoDB we will need to add one more npm package called <em><a href=\"https://www.npmjs.com/package/mongoose\">mongoose</a></em>. Mongoose is object modeling tool designed for MongoDB, about mongoose.js you can find a lot more in the <em><a href=\"https://mongoosejs.com/\">documentation</a></em>. To start using mongoose firstly we need to install in with <code>npm i mongoose</code> in the terminal and import the package in top of the app.js file.</p>\n<pre><code class=\"language-javascript\">const mongoose = require('mongoose');\n//to use mongoose you will need to config. your local mongo db, \n//I have done mine with robo3t you can find it https://robomongo.org/\nmongoose.connect('mongodb://localhost:27017/your_local_db_name', {useNewUrlParser: true});\n</code></pre>\n<p>To use the mongoose first we will need to configure a model (or schema). In the root folder, we will now add a model folder, and here we will define all of our models. Let's define the post model, to do that we need to create <code>post.js</code> inside the model's folder.</p>\n<p><strong>post.js</strong></p>\n<pre><code class=\"language-javascript\">const mongoose = require('mongoose');\n\n//Here we are defining our post model\nconst postSchema = mongoose.Schema({\n    _id: mongoose.Schema.Types.ObjectId,\n    title: String,\n    body: String\n});\n\nmodule.exports = mongoose.model('Post', postSchema);\n</code></pre>\n<p><ad-incontent></ad-incontent></p>\n<p>To use our new post model we need to import it to the <code>posts.js</code> file in the routes folder. After that we will update all our routes, like in the following example:</p>\n<p><strong>posts.js</strong></p>\n<pre><code class=\"language-javascript\">const express = require('express');\nconst router = express.Router();\nconst mongoose = require('mongoose');\nconst Post = require('../models/post'); //importing the model\n\nrouter.get('/', (req, res, next) => {\n    //returning all the posts\n    Post.find((error, posts) => {\n        if(error) return res.status(500).json({error: error});\n        return res.status(200).json({\n            posts: posts\n        });\n    });\n});\n\nrouter.get('/:postId', (req, res, next)=> {\n    //finding the post by id and returning with the response\n    Post.findById(req.params.postId, (error, post) => {\n        if(error) return res.status(500).json({error: error});\n        return res.status(200).json({\n            post: post\n        });\n    });\n});\n\n\nrouter.post('/', (req, res, next) => {\n    //creating new post object\n    const post = new Post({\n        _id: new mongoose.Types.ObjectId(),\n        title: req.body.title,\n        body: req.body.body\n    });\n    //method provides by the mongoose for saving the object\n    post.save((error, result) => {\n        if(error) return res.status(500).json({error: error});\n        return res.status(200).json({\n            message: 'New post created',\n            createdPost: post\n        })\n    });\n});\n\nrouter.put('/:postId', (req, res, next) => {\n    //updating a post by id\n    Post.updateOne({_id: req.params.postId}, {$set: {title: req.body.title, body: req.body.body}}, (error, post) => {\n        if(error) return res.status(500).json({error: error});\n        return res.status(200).json({\n            message: 'Post updated',\n            updatedPost: post\n        });\n    });\n});\n\nrouter.delete('/:postId', (req, res, next) => {\n    //deleting a post by id\n    Post.deleteOne({_id: req.params.postId}, (error, post) => {\n        if(error) return res.status(500).json({error: error});\n        return res.status(200).json({\n            message: 'Post removed',\n            removedPost: post\n        });\n    });\n});\n\nmodule.exports = router;\n</code></pre>\n<p>With this, we are completing one part of our rest API. You can find all of the code in my <strong><a href=\"https://github.com/AleksandarVasilevski/node-rest-api\">GitHub</a></strong> repository.</p>\n<p>If you want to learn Node.js there is a great course on Udemy which I highly recommend you to take, you can find it on the link below:</p>\n<p><a href=\"https://click.linksynergy.com/link?id=LFcSQV4ezac&offerid=507388.922484&type=2&murl=https%3A%2F%2Fwww.udemy.com%2Fcourse%2Fthe-complete-nodejs-developer-course-2%2F\"><IMG border=0 src=\"https://i.udemycdn.com/course/480x270/922484_52a1_8.jpg\" ><div >The Complete Node. js Developer Course (3rd Edition)</div></a><IMG border=0 width=1 height=1 src=\"https://ad.linksynergy.com/fs-bin/show?id=LFcSQV4ezac&bids=507388.922484&type=2&subid=0\" ></p>\n<p>Alternatively, I will recommend you a great node.js book for beginners:</p>\n<p><a href=\"https://www.amazon.com/gp/product/1484201884/ref=as_li_tl?ie=UTF8&camp=1789&creative=9325&creativeASIN=1484201884&linkCode=as2&tag=aleksandarvas-20&linkId=3541325718ee02aa7ccee84bd6de0acc\" style=\"font-weight:bold; color:#ff7a59;\">Beginning Node.js</a></p>\n<p>I hope you can understand how to build rest API in Node.js and Express.js, we have also seen a bit of MongoDB too, if you find this article helpful please share it.</p>","frontmatter":{"path":"/how-to-build-rest-api-with-nodejs-and-expressjs/","date":"2019-09-25T12:50:49.619Z","title":"How to Build Rest API with Node.js, Express.js and MongoDB","author":"Aleksandar Vasilevski","image":"/assets/nodejs-cover.png","category":"Nodejs","tags":"#nodejs #expressjs #javascript #mobgodb","featured":false}}},{"node":{"id":"e1957d29-45a0-5907-80de-d1c8b73be1ac","html":"<p><img src=\"/assets/java-script-101-logo.png\" alt=\"javascript-logo\"></p>\n<p>This article is part of the JavaScript 101 series, you can find the previous part on the following link: <a href=\"https://www.codespot.org/javascript-101-conditionals-and-loops/\" style=\"font-weight:bold; text-transform:uppercase; color:#ff7a59;\">JavaScript 101: Conditionals and Loops</a>.</p>\n<h2>Into Functions</h2>\n<p>A <strong>function</strong> is a set of one or more statements that take inputs, do some specific computation and produce output. The idea behind the functions is to not repeat writing the same code over and over again for different inputs. JavaScript is a programming language that supports the use of functions, there are already build in functions like: <code>console.log()</code>, <code>alert()</code>, etc..</p>\n<p><ad-incontent></ad-incontent></p>\n<p>A function in javascript can be created using the keyword <em>function</em>, here is the syntax to define a function:</p>\n<pre><code class=\"language-javascript\">function functionName(param1, param2){\n  // Function body\n}\n</code></pre>\n<p>If we want to create a function in JavaScript, first we have to use the keyword <em>function</em>, the second part is the name of the function which can be what we want, commonly is used a camel case naming convention, the third part is the function and parameters within parenthesis(param1 and param2), and lastly is the body of the function inside the <code>{}</code>.</p>\n<p>Function parameters or arguments are additional information passed to the function. The parameters or the arguments are passed to the function within parentheses and are separated by commas. A function in JavaScript can be without parameters too, but also can have any number of parameters too.</p>\n<p>After defining a function, the next step is to call the function. We can call a function by using the function name and the parameters enclosed between parenthesis. Here is the syntax to call the function:</p>\n<pre><code class=\"language-javascript\">functionName(param1, param2);\n</code></pre>\n<p>A function also can return a value at the end of the body. If we want to return some value from the computation we need to use the <em>return</em> keyword in the statement, here is the syntax to return a value:</p>\n<pre><code class=\"language-javascript\">function functionName(param1, param2){\n  // Function body\n  return param1 + param2;\n}\n</code></pre>\n<p>The value can be returned to the variable sum in the function declaration, you can check on the next example:</p>\n<pre><code class=\"language-javascript\">var sum = functionName(param1, param2);\n</code></pre>\n<p><ad-incontent></ad-incontent></p>\n<h2>Functions Scope</h2>\n<p>Each function creates a new scope in JavaScript, scope determines the visibility of these variables(you can go back and read more about variables <em><a href=\"https://www.codespot.org/javascript-101-variables-and-data-types\">here</a></em>). Variables that are defined inside a function are not accessible from outside the function. </p>\n<p>Functions are very important for writing clean and good structured code.</p>\n<p>Next part: <a href=\"https://www.codespot.org/javascript-101-scope-and-closures/\" style=\"font-weight:bold; text-transform:uppercase; color:#ff7a59;\">JavaScript 101: Scope and Closures</a>.</p>","frontmatter":{"path":"/javascript-101-functions/","date":"2019-09-23T11:55:49.619Z","title":"JavaScript 101: Functions","author":"Aleksandar Vasilevski","image":"/assets/java-script-101-logo.png","category":"JavaScript","tags":"#javascript #javascript101","featured":false}}},{"node":{"id":"5cf91575-a087-5c72-baa6-bb336ad6d687","html":"<p><img src=\"/assets/netlify-cover.jpg\" alt=\"netlify-cover\"></p>\n<p><a href=\"https://www.netlify.com\"><strong>Netlify</strong></a> is a platform that provides tools for deploying websites in just a few clicks. it’s completely free for an unlimited number of projects for individuals, making it ideal for personal websites and small projects. To deploy your site, you need to commit your code into a git repository and push it to the git hosting provider (such as Bitbucket, GitLab, or GitHub). For this example, I will be using a GitHub.\nOnce you have pushed your code to your Github repository, you will need to visit the Netlify Create a new site page: <a href=\"https://app.netlify.com/start\">https://app.netlify.com/start</a>. If you don't have a Netlify account, you can use your GitHub (or other provider) account to sign-in/log-in.</p>\n<p><ad-incontent></ad-incontent></p>\n<h2>Connect to git provider</h2>\n<p><img src=\"/assets/how-to-deploy-a-webiste-to-netlify-1.jpg\" alt=\"netlify-deployment-p1\"></p>\n<p>In the next section Continuous Deployment, select the git provider that you will be using, in our case GitHub. At this point, Netlify will ask you to authorize access to your GitHub account. Once the permission to access your GitHub by Netlify is authorized, it will ask you to choose the project you want to host it, like in the photo below:</p>\n<h2>Pick a repository</h2>\n<p><img src=\"/assets/how-to-deploy-a-webiste-to-netlify-2.jpg\" alt=\"netlify-deployment-p2\"></p>\n<p>In the next section, you need to set Netlify which branch to deploy from. In git, the default branch is named master, use this unless you don't want to deploy to another branch. Netlify has continuous deployment which means every time you push your code to your branch Netlify will re-deploy the site. This feature allows fast changes on your website.</p>\n<h2>Build options, and deploy!</h2>\n<p><img src=\"/assets/how-to-deploy-a-webiste-to-netlify-3.jpg\" alt=\"netlify-deployment-p3\"></p>\n<p>If you have built your site using a static site generator (such as Gatsby.js) you will need to specify two more options. The first one is the build command that it is the command you use to build your static files (such as gatsby build). The second one is the publish directory which is the directory where your generated files are located.</p>\n<p><ad-incontent></ad-incontent>\\</p>\n<p>Once you set all the required settings, you can Deploy the site. After a short time, your site will be available at a URL provided by Netlify. You can change the URL to something for example [something..].netlify.com you can find it at Settings / General / Site details. If you have a custom domain name, Netlify also provides a free TLS certificate with every custom domain name.</p>","frontmatter":{"path":"/how-to-deploy-a-website-to-netlify/","date":"2019-09-21T20:35:49.619Z","title":"How to Deploy A Website to Netlify","author":"Aleksandar Vasilevski","image":"/assets/netlify-cover.jpg","category":"Deployment","tags":"#netlify #deployment","featured":false}}},{"node":{"id":"959a9fa2-61ac-5aba-8179-254d7609e898","html":"<p><img src=\"/assets/java-script-101-logo.png\" alt=\"javascript-logo\"></p>\n<p>This article is part of the JavaScript 101 series, you can find the previous part on the following link: <a href=\"https://www.codespot.org/javascript-101-variables-and-data-types/\" style=\"font-weight:bold; text-transform:uppercase; color:#ff7a59;\">JavaScript 101: Variables and Data Types</a>.</p>\n<h2>Conditionals</h2>\n<p>In the programming conditional statement, conditional expression or simply a conditional is a feature, which performs different computations whether a boolean condition is true or false.\nA conditional is sometimes referred to as an \"if-else\".</p>\n<p><ad-incontent></ad-incontent></p>\n<p><strong>Let's see a simple example</strong></p>\n<pre><code class=\"language-javascript\">if(boolean){\n  //if boolean is true do this\n  return 'It is true'\n}else{\n  //else do this\n  return 'It is not true'\n}\n</code></pre>\n<p><img src=\"/assets/if-else-diagram.png\" alt=\"if-else\"></p>\n<p>Conditionals exist in other forms besides the if-else. For example, the switch statement can be used as a shortcut for a couple series of if-else statements.</p>\n<h2>Loops</h2>\n<p>A loop is a sequence of statements which is specified once but which may be carried out several times in succession. The code inside the loop is computed a specified number of times (for each of a collection of items, until some condition is met or indefinitely).\nThere are a couple of types of loops most used are: \"for loop\", \"while loop\" and \"for each\".</p>\n<p>A for loop repeats until a specified condition evaluates to false. A for statement looks as follows:</p>\n<pre><code class=\"language-javascript\">for (var i = 0; i &#x3C; 5; i++){\n  console.log(i)\n}\n</code></pre>\n<p>And we got:</p>\n<pre><code class=\"language-javascript\">0\n1\n2\n3\n4\n</code></pre>\n<p>A while loop executes its statements as long as a specified condition evaluates to true. A while statement looks as follows:</p>\n<pre><code class=\"language-javascript\">var i = 0\nwhile (i &#x3C; 5){\n  console.log(i)\n  i = i + 1\n}\n</code></pre>\n<p>And again we got:</p>\n<pre><code class=\"language-javascript\">0\n1\n2\n3\n4\n</code></pre>\n<p>And the last one foreach calls a function(we will see how functions work in later chapters) once for each element in an array, in order. A foreach statement looks as follows:</p>\n<pre><code class=\"language-javascript\">var numbers = [1, 2, 3, 4]\nnumbers.forEach(myFunction);\n\nfunction myFunction(item, index){\n  console.log(item)\n}\n</code></pre>\n<p>And again we got:</p>\n<pre><code class=\"language-javascript\">0\n1\n2\n3\n4\n</code></pre>\n<p><ad-incontent></ad-incontent></p>\n<p>Conditional and loops are building blocks for Computer Science.</p>\n<p>Next part: <a href=\"https://www.codespot.org/javascript-101-functions/\" style=\"font-weight:bold; text-transform:uppercase; color:#ff7a59;\">JavaScript 101: Functions</a>.</p>","frontmatter":{"path":"/javascript-101-conditionals-and-loops/","date":"2019-09-21T17:35:49.619Z","title":"JavaScript 101: Conditionals and Loops","author":"Aleksandar Vasilevski","image":"/assets/java-script-101-logo.png","category":"JavaScript","tags":"#javascript #javascript101","featured":false}}},{"node":{"id":"0d27d24f-491c-556b-bc0c-63e6210a2626","html":"<p><img src=\"/assets/es6-promises.jpg\" alt=\"&#x27;es6-promises&#x27;\"></p>\n<p>This article is part of the Async JavaScript series, you can find the previous part on the following link: <a href=\"https://www.codespot.org/async-javascript-part-1-the-callback/\" style=\"font-weight:bold; text-transform:uppercase; color:#ff7a59;\">Async JavaScript Part 1: The Callback</a>.</p>\n<h2>What is a Promise?</h2>\n<p>Promises make it easy for us to manage the asynchronous operation, they were designed to solve many of the problems we run into when using callbacks (you can read the first part about callbacks <a href=\"https://www.codespot.org/async-javascript-part-1-the-callback/\"><em>here</em></a>) in our application. To be more precise, The Promise object represents completion or failure, of an asynchronous operation, and its resulting value. Promises are built on callback patterns so you need to understand how callbacks work before you can use them.</p>\n<p><strong>Let's see a simple example</strong></p>\n<pre><code class=\"language-javascript\">const doWorkPromise = new Promise((resolve, reject) => {\n  setTimeout(() => {\n    resolve(2)\n  }, 1000)\n})\n</code></pre>\n<p>So we have two functions named <code>resolve</code> and <code>reject</code>, if things went well and we got the result that we were expecting we call <code>resolve</code>, if things went bad we call <code>reject</code>.</p>\n<p><ad-incontent></ad-incontent></p>\n<pre><code class=\"language-javascript\">doWorkPromise.then((result) => {\n  console.log('success', result)\n})\n</code></pre>\n<p>In the second part, we are using <code>then()</code> method, which allows us to register a function to run when things go well(when <code>resolve</code> is called), and we get access to the data from the first and only param (<code>result</code>). So these functions only get executed when things go well.</p>\n<pre><code class=\"language-javascript\">'success'\n2\n</code></pre>\n<p>And we got the result of <code>success</code> and <code>2</code>.\nIn real life, things don't always go well, and sometimes we may call the <code>reject()</code> and pass the error message.</p>\n<p><strong>Let's see the second example</strong></p>\n<pre><code class=\"language-javascript\">const doWorkPromise = new Promise((resolve, reject) => {\n  setTimeout(() => {\n    reject('We have problems')\n  }, 1000)\n})\n\ndoWorkPromise.then((result) => {\n  console.log('success', result)\n}).catch((error) => {\n  console.log('error', error)\n})\n</code></pre>\n<p>If we call reject <code>then()</code> is not gonna run, it only runs when it is called <code>resolve()</code>. But we can chain on another method <code>catch()</code> that allows us to run a function when <code>reject()</code> is called. And we got:</p>\n<pre><code class=\"language-javascript\">'error'\n'We have problems'\n</code></pre>\n<p><ad-incontent></ad-incontent></p>\n<p><strong>We can see in the image how they work</strong>\n<img src=\"/assets/promises-schema.png\" alt=\"&#x27;promises-scheme&#x27;\"></p>\n<p>In most of the cases, we won't create new promises but we will just be using <code>then()</code> and <code>catch()</code>.</p>\n<p><strong>Let's see the third example</strong></p>\n<pre><code class=\"language-javascript\">let promise = fetch('api/give-me-json');\npromise.then((response) => {\n  console.log(response)\n}).catch((error) => {\n  console.log(error)\n})\n</code></pre>\n<p>There are clear advantages when working with promises, the code is much cleaner.</p>\n<p>Next part: <a href=\"https://www.codespot.org/async-javascript-part-3-async-await/\" style=\"font-weight:bold; text-transform:uppercase; color:#ff7a59;\">Async JavaScript Part 3: Async/Await</a>.</p>","frontmatter":{"path":"/async-javascript-part-2-promises/","date":"2019-09-20T10:45:49.619Z","title":"Async JavaScript Part 2: Promises","author":"Aleksandar Vasilevski","image":"/assets/es6-promises.jpg","category":"JavaScript","tags":"#javascript #async #es6","featured":false}}},{"node":{"id":"ac380687-505d-554a-a0cc-daadfd13d1a7","html":"<h2>5. Notepad ++</h2>\n<p><img src=\"/assets/notepad++.jpg\" alt=\"notepad++\"></p>\n<p><a href=\"https://notepad-plus-plus.org/\">Notepad++</a> is the simplest text editor by far and that's why it is so popular at beginners,.It’s a code editor, plain and simple. If you are just starting with coding it is the best text editor for you, so you won't get overwhelmed by the environment offered up by other text editors. A lot of experienced developers are using Notepad++ as their everyday text editor because it’s light, effective, and does what it needs to do. It was developed in 2003 by Don Ho and even after 16 years, it continues to be one of the most credible text editor for developers and programmers. It has been rated as the \"most popular text editor\" and \"most used text editor\" by Lifehacker and Stack Overflow,</p>\n<p>There is one downside, it is available just for Windows users.</p>\n<p><strong><a href=\"https://notepad-plus-plus.org/\">Download Notepad++</a></strong></p>\n<p><ad-incontent></ad-incontent></p>\n<h2>4. Atom</h2>\n<p><img src=\"/assets/atom.jpg\" alt=\"atom\"></p>\n<p><a href=\"https://atom.io/\">Atom</a> was first started by Github in 2014 and now owned by Microsoft. Atom is a free and open-source, and highly customizable it offers thousands of packages to the users. The best part is that packages install easily by just typing the specific command. The interface is highly customizable that gives ample scope for personalization where one can change looks, fonts and more. A hackable text editor for the 21st century by its admission, Atom is perfect for first-timers as well as veteran developers for text editors.</p>\n<p><strong><a href=\"https://atom.io/\">Download Atom</a></strong></p>\n<h2>3. Vim</h2>\n<p><img src=\"/assets/vim.jpg\" alt=\"vim\"></p>\n<p><a href=\"https://www.vim.org/\">Vim</a> is the text editor from coders for coders and it is the hardest one to master it. Vim was started in 1991 back then, it was considered one of the most prominent text editors. This makes it one of the oldest text editors, and it’s quite impressive that Vim is still being used by developers around the world. Vim has a steep learning curve and it is not newbie-friendly, but once you get past the UI, you’ll see why the text editor is designed the way it is. </p>\n<p><strong><a href=\"https://www.vim.org/\">Download Vim</a></strong></p>\n<h2>2. Sublime Text</h2>\n<p><img src=\"/assets/sublime-text.jpg\" alt=\"sublime-text\"></p>\n<p><a href=\"https://www.sublimetext.com/3\">Sublime Text</a> feature-rich code editor available from 2008, it was developed by Jon Skinner and Will Bond and it has been a top-selling editor for eleven years. The User Interface is beautiful it is designed for code and It is written in C++ and Python. Sublime Text offers a rich package repository that extends its features far beyond the initial download. Sublime Text is fit for new developers as well as for experienced developers, it is the right editing tool for smooth and fast editing.</p>\n<p>While Sublime Text cost $80 it can be used indefinite with its never-ending trial.</p>\n<p><strong><a href=\"https://www.sublimetext.com/3\">Download Sublime Text 3</a></strong></p>\n<p><ad-incontent></ad-incontent></p>\n<h2>1. Visual Studio Code</h2>\n<p><img src=\"/assets/vscode.jpg\" alt=\"vscode\"></p>\n<p><a href=\"https://code.visualstudio.com/\">Visual Studio Code</a> or (VS Code) has become the standard for software development in the last few years. Visual Studio Code was released by Microsoft in 2015 and it is available on all major platforms (Windows, Mac, Linux) and can do most of the tasks of an IDE with the right configuration and plugin library. IntelliSense feature is the one we found most important, which takes syntax highlighting and auto-completion to the next level. Visual Studio Code is open source and the community work very hard to keep it on the top. Visual Studio Code is built with Node.js and Electron.</p>\n<p><strong><a href=\"https://code.visualstudio.com/\">Download Visual Studio Code</a></strong></p>","frontmatter":{"path":"/top-5-best-text-editors-for-2019/","date":"2019-09-17T10:42:15.598Z","title":"Top 5 Best Text Editors for 2019","author":"Aleksandar Vasilevski","image":"/assets/vim_screen.jpg","category":"Tools","tags":"#texteditor #notepad++ #atom #vim #sublimetext #vscode","featured":false}}},{"node":{"id":"fe5c0413-8719-5e7c-a8df-4b5d61b01207","html":"<p><img src=\"/assets/java-script-101-logo.png\" alt=\"javascript-logo\"></p>\n<p>This article is part of the JavaScript 101 series, you can find the previous part on the following link: <a href=\"https://www.codespot.org/javascript-101-into-programming/\" style=\"font-weight:bold; text-transform:uppercase; color:#ff7a59;\">JavaScript 101: Into Programming</a>.</p>\n<p><strong>JavaScript</strong>  often called <strong>JS</strong>, is a high-level, interpreted scripting language that conforms to the ECMAScript specification. JavaScript is a dynamic typed, prototype-based object-orientated language with functions as first-class citizens.</p>\n<p>JavaScript is one of the core technologies of the Web, it enables interactive web pages and is an essential part of web applications. The majority of websites use it, and major web browsers have a dedicated JavaScript engine.</p>\n<p>As a multi-paradigm language, JavaScript supports event-driven, functional, and imperative (including object-oriented and prototype-based) programming styles.</p>\n<p>Initially implemented only on client-side in web browsers, JavaScript engines are now embedded in many other types of software, including server-side in web servers and databases, and in non-web such as word processors and PDF software, and in runtime environments that make JavaScript available for writing mobile and desktop applications, including desktop widgets.</p>\n<p><ad-incontent></ad-incontent></p>\n<h2>Variables</h2>\n<p>Variables are containers for storing data values. JavaScript uses reserved keyword var ( let and const were also added in ES6 ) to declare a variable. A variable must have a unique name.. Storing a value in a variable is called variable initialization using equal to (=) operator. You can do variable initialization at the time of variable creation or at a later point in time when you need that variable.</p>\n<p>In the example below, we are declaring and initializing two variables named x and y with values 5 and 10.</p>\n<pre><code>var x = 5;  \nvar y = 10;\n</code></pre>\n<p>JavaScript is an untyped language. This means that a JavaScript variable can hold a value of any data type.</p>\n<p>There are two types of variables in JavaScript: local variable and global variable.</p>\n<ul>\n<li>Global Variables − A global variable has global scope which means it can be defined anywhere in your JavaScript code.</li>\n<li>Local Variables − A local variable will be visible only within a function where it is defined. Function parameters are always local to that function.</li>\n</ul>\n<h2>Array</h2>\n<p>In JavaScript, array is a variable that is used to store different elements. It is often used to store a list of elements and access them by a single variable. There are two ways to declare an array, but most of the time's option 1 is used.</p>\n<pre><code class=\"language-javascript\">var list = []; // option 1 \nvar list = new array(); // option 2\n</code></pre>\n<p>Initialization of an Array:</p>\n<pre><code class=\"language-javascript\">var list = [1, 2, 3]; // option 1 \nvar list = new array(1, 2, 3); // option 2\n</code></pre>\n<p>In the code snippet above we have an array with a name of \"list\" with three elements <code>1</code> at index 0, <code>2</code> at index 1, <code>3</code> at index 2. Arrays start from index 0. Let's see how we can access an element from an array:</p>\n<pre><code class=\"language-javascript\">var list = [1, 2, 3];\nconsole.log(list[0])\n</code></pre>\n<p>And we got the first element with a value of <code>1</code>. Like in the example you can access every element by its index, using <code>[]</code> and the index of the element inside.</p>\n<p><ad-incontent></ad-incontent></p>\n<h2>Data Types</h2>\n<p>There are six primitive data types and the last one is object data type in JavaScript.</p>\n<ol>\n<li><strong>Number</strong>  represents both integer and floating-point numbers.</li>\n<li><strong>Boolean</strong> represents a logical entity and can have only two values:  <code>true</code>  and  <code>false</code>.</li>\n<li><strong>String</strong>  type is used to represent textual data. It can be used as <code>' '</code> or <code>\" \".</code></li>\n<li><strong>Undefined</strong> has a value of  <code>undefined</code>  when value is not assigned.</li>\n<li><strong>Null</strong>  can have just one value:  <code>null</code>. It’s just a special value that represents nothing.</li>\n<li><strong>Symbol</strong>  is a unique and immutable value and may be used as the key of an Object property.</li>\n<li><strong>Object</strong>  in computer science is an object with a value in memory which is possibly referenced by an identifier.</li>\n</ol>\n<p>Next part: <a href=\"https://www.codespot.org/javascript-101-conditionals-and-loops/\" style=\"font-weight:bold; text-transform:uppercase; color:#ff7a59;\">JavaScript 101: Conditionals and Loops</a>.</p>","frontmatter":{"path":"/javascript-101-variables-and-data-types/","date":"2019-09-16T10:35:49.619Z","title":"JavaScript 101: Variables and Data Types","author":"Aleksandar Vasilevski","image":"/assets/java-script-101-logo.png","category":"JavaScript","tags":"#javascript #javascript101","featured":false}}},{"node":{"id":"8493004d-449f-5a42-8e3d-ebe2796feb69","html":"<p><img src=\"/assets/java-script-101-logo.png\" alt=\"javascript-logo\"></p>\n<h2>Code</h2>\n<p>A program is often referred to as source code or just code. Program is a set of special instructions to tell the computer what tasks to perform.  Code usually is saved to the file but with JavaScript, you can write code directly into a developer console in a browser.</p>\n<p>The rules of combinations of instructions is called a computer language, sometimes referred to as its syntax.</p>\n<p><ad-incontent></ad-incontent></p>\n<h2>Statements</h2>\n<p>In a computer language, inputs line numbers, and operators that perform a specific task is a statement. In JavaScript, a statement might look as follows:</p>\n<p><code>x = y + 5</code></p>\n<p>The characters x and y are called variables (see <a href=\"https://codespot.org/javascript-101-variables-and-data-types\">JavaScript 101: Variables and Data Types</a> for more about variables), which are like containers where you can store values.</p>\n<p>Number 5 is called a literal value because it stands alone without being stored in a variable.</p>\n<p>The = and + characters are operators, they perform actions with the values and variables such as assignment and mathematic operation.</p>\n<p>The statement x = y + 5; tells the computer, to get the current value stored in the variable y, add that value with 5, then store the result back into another variable x.</p>\n<p>Programs are just collections of many such statements, which together describe all the steps that it takes to perform your program.</p>\n<h2>Expressions</h2>\n<p>Statements are made up of one or more expressions. An expression is any reference to a variable or value, or a set of variables and values combined with operators.</p>\n<p>Here is an example:</p>\n<p><code>x = y + 5</code></p>\n<p>This statement has four expressions in it:</p>\n<ol>\n<li><code>5</code> is a literal value expression</li>\n<li><code>y</code> is a variable expression</li>\n<li><code>y + 5</code> is an arithmetic expression</li>\n<li><code>x = y + 5</code> is an assignment expression</li>\n</ol>\n<p><ad-incontent></ad-incontent></p>\n<h2>Executing a Program</h2>\n<p>The program needs to be executed, also referred to as running the program.</p>\n<p>For some computer languages, this translation of commands is typically done from top to bottom, line by line, every time the program is run, which is usually called interpreting the code.</p>\n<p>For other languages, the translation is done ahead of time, called compiling the code, so when the program runs later, what's running is the already compiled computer instructions ready to go.</p>\n<h2>Output</h2>\n<p>Using <code>console.log(..)</code> you can create output by printing the value to the console.</p>\n<p>Another way of creating output that you can see is to run an <code>alert(..)</code> statement.</p>\n<h2>Input</h2>\n<p>The most common way that happens is for the HTML page to show form elements to a user that they can type into, and then using JavaScript to read those values into your program's variables.</p>\n<h2>Operators</h2>\n<p>Operators are how we perform actions on variables and values.</p>\n<p>There are two types of operators:</p>\n<ul>\n<li>Arithmetic Operators</li>\n<li>Logical Operators</li>\n<li>Comparison Operators</li>\n<li>Assignment Operators</li>\n<li>Conditional Operators</li>\n</ul>\n<p><ad-incontent></ad-incontent></p>\n<p><strong>Arithmetic operators</strong> are used to perform mathematical operations between numeric operands. There are seven of them:</p>\n<ol>\n<li><code>+</code> Adds two numeric operands.</li>\n<li><code>-</code> Subtract right operand from the left operand</li>\n<li><code>*</code> Multiply two numeric operands.</li>\n<li><code>/</code> Divide left operand by the right operand.</li>\n<li><code>%</code> Modulus operator. Returns remainder of two operands.</li>\n<li><code>++</code> Increment operator. Increase operand value by one.</li>\n<li><code>--</code> Decrement operator. Decrease value by one.</li>\n</ol>\n<p><strong>Logical operators</strong> are used to combine two or more conditions. JavaScript includes the following logical operators.</p>\n<ol>\n<li><code>&#x26;&#x26;</code> is known as AND operator. It checks whether two operands are non-zero (0, false, undefined, null or \"\" are considered as zero), if yes then return 1 otherwise 0.</li>\n<li><code>||</code> is known as OR operator. It checks whether any one of the two operands is non-zero (0, false, undefined, null or \"\" is considered as zero).</li>\n<li><code>!</code> is known as NOT operator. It reverses the boolean result of the operand (or condition).</li>\n</ol>\n<p><strong>Comparison operators</strong> are used to compare two operands and return Boolean value true or false.</p>\n<ol>\n<li><code>==</code> Compares the equality of two operands without considering type.</li>\n<li><code>===</code> Compares equality of two operands with type.</li>\n<li><code>!=</code> Compares the inequality of two operands.</li>\n<li><code>></code> Checks whether left-side value is greater than right side value. If yes then returns true otherwise false.</li>\n<li><code>&#x3C;</code> Checks whether the left operand is less than the right operand. If yes then returns true otherwise false.</li>\n<li><code>>=</code> Checks whether the left operand is greater than or equal to the right operand. If yes then returns true otherwise false.</li>\n<li><code>&#x3C;=</code> Checks whether the left operand is less than or equal to the right operand. If yes then returns true otherwise false.</li>\n</ol>\n<p><strong>Assignment operators</strong> are used to assign values to variables.</p>\n<ol>\n<li><code>=</code> Assigns right operand value to left operand.</li>\n<li><code>+=</code> Sums up left and right operand values and assign the result to the left operand.</li>\n<li><code>-=</code> Subtract right operand value from left operand value and assign the result to the left operand.</li>\n<li><code>*=</code> Multiply left and right operand values and assign the result to the left operand.</li>\n<li><code>/=</code> Divide left operand value by right operand value and assign the result to the left operand.</li>\n<li><code>%=</code> Get the modulus of left operand divide by the right operand and assign resulted modulus to the left operand.</li>\n</ol>\n<p><strong>Conditional operators</strong> are used to compare values, like short if-else condition.</p>\n<p><code>&#x3C;condition> ? &#x3C;value1> : &#x3C;value2>;</code></p>\n<p>Next part: <a href=\"https://www.codespot.org/javascript-101-variables-and-data-types/\" style=\"font-weight:bold; text-transform:uppercase; color:#ff7a59;\">JavaScript 101: Variables and Data Types</a>.</p>","frontmatter":{"path":"/javascript-101-into-programming/","date":"2019-09-15T20:35:49.619Z","title":"JavaScript 101: Into Programming","author":"Aleksandar Vasilevski","image":"/assets/java-script-101-logo.png","category":"JavaScript","tags":"#javascript #javascript101","featured":false}}},{"node":{"id":"7f893377-7950-57f7-9754-8ab698c74477","html":"<p><img src=\"/assets/callback.jpg\" alt=\"callback\"></p>\n<h2>What is Callback?</h2>\n<p>Callback is a function that is to be executed after another function has finished executing.</p>\n<p>JavaScript functions can take other functions as arguments and can be returned by other functions. These functions are called higher-order functions. Any function that is passed as an argument is called a  <strong>callback function</strong>.</p>\n<p>** Let's see simple example**</p>\n<pre><code class=\"language-javascript\">function first(){  \n console.log(“First function finished”);  \n}function second(){  \n console.log(“Second function finished”);  \n}first();  \nsecond();\n</code></pre>\n<p>So we have two functions named  <code>first</code>  and  <code>second</code>  that are printing log. As you would expected, the function  <code>first</code>  is executed first, and the function  <code>second</code>  is executed second.</p>\n<pre><code class=\"language-javascript\">// First function finished  \n// Second function finished\n</code></pre>\n<p>But what if  <code>first</code>  function contains some code that won’t execute immediately? For example, an API request where we have to send the request then wait for a response? Let's use the <code>setTimeout</code>  function and pretend that it is a server response. With  <code>setTimeout</code>  we are simply saying to this after x time in our case 1000ms or 1s.</p>\n<pre><code class=\"language-javascript\">function first(){  \n setTimeout(function() {  \n console.log(“First function finisher”);  \n }, 1000);  \n}function second(){  \n console.log(“Second function finished”);  \n}first();  \nsecond();\n</code></pre>\n<p>And we got:</p>\n<pre><code class=\"language-javascript\">// Second function finished  \n// First function finished\n</code></pre>\n<p>Even we called  <code>first</code>  function first, we got the result of that function after the <code>second</code> function.</p>\n<p><ad-incontent></ad-incontent></p>\n<h2>Create callback</h2>\n<pre><code class=\"language-javascript\">function first(callback){  \n setTimeout(function() {  \n console.log(“First function finisher”);  \n callback();  \n }, 1000);  \n}function second(){  \n console.log(“Second function finished”);  \n}first(second);\n</code></pre>\n<p>Now we have callback argument in  <code>first</code>  function and we are passing  <code>second</code> function as callback. After  <code>setTimeout</code> has finished  <code>callback</code>  is executed and now we got:</p>\n<pre><code class=\"language-javascript\">// First function finished  \n// Second function finished\n</code></pre>\n<p>You can now understand what a callback is and how it works.</p>\n<p>Next part: <a href=\"https://www.codespot.org/async-javascript-part-2-promises/\" style=\"font-weight:bold; text-transform:uppercase; color:#ff7a59;\">Async JavaScript Part 2: Promises</a>.</p>","frontmatter":{"path":"/async-javascript-part-1-the-callback/","date":"2019-09-13T18:35:49.619Z","title":"Async JavaScript Part 1: The Callback","author":"Aleksandar Vasilevski","image":"/assets/callback.jpg","category":"JavaScript","tags":"#javascript #async","featured":false}}},{"node":{"id":"237b3a9c-3e48-58a5-9a11-ca8848f7d683","html":"<p>In this ASO guide, we will see how to improve app visibility, how to improve conversion rate with one ultimate goal to increase organic app downloads.</p>\n<h2>What is ASO?</h2>\n<p>With more and more apps and games releasing every day is it impossible to succeed without App Store Optimization or simply ASO. App Store Optimization is a never-ending process that improves mobile app visibility and conversion rate to maximize the volume of downloads.</p>\n<p><ad-incontent></ad-incontent></p>\n<p>There are three key steps to great optimization:</p>\n<ul>\n<li>Keyword optimization</li>\n<li>A/B testing</li>\n</ul>\n<h1>1. Keyword optimization</h1>\n<p>Keyword optimization is the first step to get visibility, you need to target the right keywords for your app of the game. Start by building a list of keywords.</p>\n<h2>App Name / Title</h2>\n<p>This field is the strongest ranking factor for search rankings and also plays a role in conversion rate to download. On Google Play Store you can use up to 50 characters, on App Store you are limited to just 30 characters. Try to have some unique brand name, and include couple more keywords that give your app purpose or value.</p>\n<p><img src=\"/assets/google-maps-aso.png\"></p>\n<h2>Short Description</h2>\n<p>The second most important field is used to show the value of your app or game delivers, you should include your main keywords here too. Short Description affects both search rankings and conversion rates to download.</p>\n<p><img src=\"/assets/messenger-aso.png\"></p>\n<h2>Description</h2>\n<p>The long description plays an important role in both visibility and conversion rate. You have 4000 characters to make a well-structured description, you need to introduce as many keyword combinations here as possible and use the most important ones few times (4–5) to keep the density of keywords. The most important part is the first 3 lines of your description.</p>\n<h2>Icon, Screenshots and Feature Graphics (Play Store)</h2>\n<p>Your app icon should be really impressive, it is the first thing the user sees when an app is discovered. So you need to be creative and unique, but still, keep it simple.</p>\n<p>Screenshots help you to show app most important features and give the user reason to install the app or game, Try to use all screenshot spaces and use the first 3 as the most important ones.</p>\n<p>On Google Play Store you can have Feature Graphics too (image or video) this element plays an important role in conversion rate.</p>\n<p><ad-incontent></ad-incontent></p>\n<h1>2. A/B testing</h1>\n<p>A/B testing is used to improve the conversion rate of the app or game. Start testing with one element at a time, test for 5–7 days with consistent traffic to see the best results. Start with your icon as it affects both CTR and conversion rate.</p>","frontmatter":{"path":"/guide-for-app-store-optimization-aso/","date":"2019-09-13T12:35:49.619Z","title":"Guide for App Store Optimization ASO","author":"Aleksandar Vasilevski","image":"/assets/google-maps-aso.png","category":"SEO","tags":"#aso #android #ios","featured":false}}}]}},"pageContext":{}},"staticQueryHashes":["2285949970","4047814605"]}