<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>Forem: Dr. Michael Garbade</title>
    <description>The latest articles on Forem by Dr. Michael Garbade (@educationecosystem).</description>
    <link>https://forem.com/educationecosystem</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F75278%2Fae1be607-5745-4df4-8af6-6e494c1172e3.jpg</url>
      <title>Forem: Dr. Michael Garbade</title>
      <link>https://forem.com/educationecosystem</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/educationecosystem"/>
    <language>en</language>
    <item>
      <title>TiDB on KubeSphere: How to Use Cloud-Native Distributed Database on Kubernetes</title>
      <dc:creator>Dr. Michael Garbade</dc:creator>
      <pubDate>Wed, 31 Mar 2021 15:46:28 +0000</pubDate>
      <link>https://forem.com/educationecosystem/tidb-on-kubesphere-how-to-use-cloud-native-distributed-database-on-kubernetes-27n6</link>
      <guid>https://forem.com/educationecosystem/tidb-on-kubesphere-how-to-use-cloud-native-distributed-database-on-kubernetes-27n6</guid>
      <description>&lt;p&gt;&lt;strong&gt;Introduction&lt;/strong&gt;&lt;br&gt;
Kubernetes has, in the recent past, become the go to standard for building applications running multiple containers. Using Kubernetes comes with the need to run cloud-native distributed databases. One of the prominently emerging cloud-native, open-source NewSQL databases is TiDB.  &lt;/p&gt;

&lt;p&gt;By deploying &lt;a href="https://www.education-ecosystem.com/suenot/2bEE4-how-to-use-rancher-kubernetes-cluster-on-hetzner-cloud"&gt;TiDB on KubeSphere&lt;/a&gt;, this article demonstrates how you can have TiDB clusters powered by Kubernetes and how to manage the clusters using an easy to use web interface. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What is TiDB and KuberSphere?&lt;/strong&gt;&lt;br&gt;
TiDB, an open-source NewSQL database, supports Hybrid Transactional and Analytical Processing (HTAP) workloads. TiDB is MySQL compatible and contains features such as; horizontal scalability, a strong consistency, and is highly available. TiDB provides users with a single, multi-purpose database solution, covering systems and services such as;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Online Transactional Processing (OLTP)&lt;br&gt;
Online Analytical Processing (OLAP), and&lt;br&gt;
Hybrid transactional/analytical processing (HTAP)&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;KubeSphere, on the other hand, is a distributed operating system managing cloud native applications with Kubernetes as its kernel, and provides plug-and-play architecture for the seamless integration of third-party applications to boost its ecosystem.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;How do you deploy TiDB on KubeSphere?&lt;/strong&gt;&lt;br&gt;
You will need a Kubernetes cluster before you deploy TiDB on KubeSphere. Installing the Kubernetes clusters require you to prepare either virtual or physical machines, and configuring network rules to enable smooth flow of traffic from one instance to the next. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;How do you prepare the environments?&lt;/strong&gt;&lt;br&gt;
KubeSphere can be installed on any infrastructure, including deploying Kubernetes by itself. Read the KubeSphere documentation for more insights. In this article, we use the QingCloud platform, provided by QingCloud, which sponsors KubeSphere. It is a highly-functional platform that enables fast deployment of Kubernetes and KubeSphere at the same time with just a few clicks.  &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Deploying the TiDB Operator&lt;/strong&gt;&lt;br&gt;
The TiDB Operator is simply an automatic operation system used for TiDB clusters in Kubernetes. The operator provides a complete management life-cycle for TiDB, which includes deployment, scaling, upgrades, fail-over, backup, and any configuration changes. The TiDB Operator helps TiDB to run seamlessly in Kubernetes clusters that are deployed on public or private clouds. You should first deploy a TiDB Operator on KubeSphere, before you deploy a TiBD cluster.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Deploying a TiDB Cluster&lt;/strong&gt;&lt;br&gt;
So, after you have deployed the TiDB Operator, you can move ahead and deploy a TiDB cluster on Kubernetes. This process of deploying a TiDB cluster is pretty much similar to deploying the TiDB operator. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;How do you Access TiDB Clusters?&lt;/strong&gt;&lt;br&gt;
Now that you have prepared your environment, deployed the TiDB operator and cluster, your apps are ready, and you may now need to focus on observability. The KubeSphere dashboard allows you to observe your applications throughout their lifecycle.&lt;/p&gt;

&lt;p&gt;You then need to verify that the apps are up and running. Kubernetes lists all running services and the port in which each service is exposed to, for easy access.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Wrapping Up&lt;/strong&gt;&lt;br&gt;
Many developers continue to move from cloud-hosted to cloud native environments. As this happens, the way DevOps builds applications and stores distributed data continues to change. This article describes how TiDB and KubeSphere are powerful tools for cloud-native applications. As &lt;a href="https://www.education-ecosystem.com/suenot/2bEE4-how-to-use-rancher-kubernetes-cluster-on-hetzner-cloud"&gt;Suenot&lt;/a&gt; describes in his project, “How to use Rancher (Kubernetes cluster) on Hetzner cloud” it is not possible to showcase all the features of TiDB and KubeSphere in a single post. &lt;/p&gt;

</description>
    </item>
    <item>
      <title>Make Money Online By Teaching People How To Build Products</title>
      <dc:creator>Dr. Michael Garbade</dc:creator>
      <pubDate>Mon, 29 Jul 2019 12:00:26 +0000</pubDate>
      <link>https://forem.com/educationecosystem/make-money-online-by-teaching-people-how-to-build-products-i5i</link>
      <guid>https://forem.com/educationecosystem/make-money-online-by-teaching-people-how-to-build-products-i5i</guid>
      <description>&lt;p&gt;Coding is one of the most lucrative skills in the industry. It opens up a plethora of options for you as a programmer.&lt;/p&gt;

&lt;p&gt;If you are looking to make money through your skills, then you are in luck! There are many ways one can earn money.&lt;/p&gt;

&lt;p&gt;One such way is teaching others how to build products.&lt;/p&gt;

&lt;p&gt;The industry is growing at a rapid pace with an ever-growing demand for coders. Just like you followed tutorials and projects to learn coding skills, there are thousands of other people who are also doing the same. Some of them are even struggling to get past the beginner phase. The new learners mostly struggle because they do not know how to transit their coding skills into a real-world project.&lt;/p&gt;

&lt;p&gt;And, this is where you get the chance to make money.&lt;/p&gt;

&lt;p&gt;If you have crossed past the beginner stage, and have started making projects of real value -- you can use your knowledge to teach people how to build products.&lt;/p&gt;

&lt;p&gt;That’s game-changing, considering that the best way to learn is to teach others. It’s easy to get started.&lt;/p&gt;

&lt;h3&gt;
  
  
  1. You do not need a significant amount of time
&lt;/h3&gt;

&lt;p&gt;One of the misconceptions about teaching people online is that you have to spend a lot. &lt;/p&gt;

&lt;p&gt;That’s not true. On average, anyone can start teaching online by just spending 4-5 hours per week. All you need to do is plan properly and execute it with precision.&lt;/p&gt;

&lt;p&gt;Building a product can take you anywhere between 2-3 weeks, depending on the complexity of the project.&lt;/p&gt;

&lt;h3&gt;
  
  
  2. No need to live stream
&lt;/h3&gt;

&lt;p&gt;Live Streams can be a great way to interact with your audience, but they lack the structure for teaching or learning. &lt;/p&gt;

&lt;p&gt;As a teacher, you have to record videos and then upload it to your website or a learning platform of your choice.&lt;/p&gt;

&lt;h3&gt;
  
  
  3. Join a platform
&lt;/h3&gt;

&lt;p&gt;There are many amazing platforms out there that let you explore the possibility of teaching others.&lt;/p&gt;

&lt;p&gt;One such platform is the Education Ecosystem that offers a &lt;a href="https://blog.education-ecosystem.com/earn-more-from-your-projects/"&gt;good earning model&lt;/a&gt;. On the platform, you can get paid per project and also for the view time. You can &lt;a href="https://www.education-ecosystem.com/creators"&gt;join the platform&lt;/a&gt; and start your journey of teaching others. &lt;/p&gt;

&lt;p&gt;In contrast, you can also upload on YouTube, but it lacks a proper earning model. Also, it requires a specific target audience -- which means that you need to bring your own audience.&lt;/p&gt;

&lt;p&gt;Another way you can make money is to create your own website, set up a Google Adsense, do proper SEO optimization and marketing. However, it may require a lot of time and commitment, which may hamper your projects.&lt;/p&gt;

&lt;p&gt;In short, we suggest you reach your audience through established learning platforms and then create a following of your own later down the path.&lt;/p&gt;

&lt;h3&gt;
  
  
  4. Freelancing
&lt;/h3&gt;

&lt;p&gt;Teaching through freelancing is also a possibility. &lt;/p&gt;

&lt;p&gt;There are many platforms such as Fiverr, Upwork, etc. where you can get gigs on teaching people. However, the gigs are mostly run short, and you may also not get the chance to record a tutorial.&lt;/p&gt;

&lt;h2&gt;
  
  
  What’s next?
&lt;/h2&gt;

&lt;p&gt;Building products is at the core of software engineering. As a programmer, you should always keep a tab on showcasing your skills and earning from it as well. Not only that will help you keep learning new things, but also make you a decent amount of money. &lt;/p&gt;

&lt;p&gt;So, what do you think about making money online teaching people how to build products? Comment below and let us know!&lt;/p&gt;

</description>
      <category>beginners</category>
      <category>career</category>
    </item>
    <item>
      <title>11 Best Tools for Blockchain Development</title>
      <dc:creator>Dr. Michael Garbade</dc:creator>
      <pubDate>Thu, 25 Jul 2019 14:39:11 +0000</pubDate>
      <link>https://forem.com/educationecosystem/11-best-tools-for-blockchain-development-3imk</link>
      <guid>https://forem.com/educationecosystem/11-best-tools-for-blockchain-development-3imk</guid>
      <description>&lt;p&gt;With the rise in popularity of blockchain, we have witnessed a drastic increase in blockchain development.&lt;/p&gt;

&lt;p&gt;No doubt that almost every company wants to take advantage of decentralized ledger technology.&lt;/p&gt;

&lt;p&gt;And this is where you come in.&lt;/p&gt;

&lt;p&gt;As a blockchain developer, you are highly valuable in the current market. If you want to stay relevant, then you need to make the most out of the blockchain development tools out there.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.education-ecosystem.com/hdhameliya/ROyDj-building-an-application-using-hyperledger-fabric/Ba85K-intro-building-an-application-using-hyperledger-2/"&gt;Hdhameliya&lt;/a&gt;, a blockchain developer from the United States, also speaks about the importance of tools and how choosing the right tool can radically improve efficiency and productivity. He is super selective in his tools and always advises to try out tools before incorporating them in the workflow.&lt;/p&gt;

&lt;h2&gt;
  
  
  10 Best Tools for Blockchain Development
&lt;/h2&gt;

&lt;h3&gt;
  
  
  &lt;a href="https://solidity.readthedocs.io/en/v0.5.3/#"&gt;Solidity&lt;/a&gt;
&lt;/h3&gt;

&lt;p&gt;Solidity is one of the most popular programming languages used in blockchain development. &lt;/p&gt;

&lt;p&gt;It supports the object-oriented paradigm and is used to write smart contracts. Ethereum dApps can also be coded with Solidity. Solidity is designed to target the Ethereum Virtual Machine(EVM). &lt;/p&gt;

&lt;p&gt;So, what makes Solidity so special? First of all, it is used in one of the most popular blockchain solutions, i.e., Ethereum. &lt;/p&gt;

&lt;p&gt;Secondly, it can be used to smart contracts which open up a variety of use-cases, especially when it comes to crowdfunding, voting, and multi-signature wallets.&lt;/p&gt;

&lt;p&gt;As a blockchain developer, you can get started by going through &lt;a href="https://solidity.readthedocs.io/en/v0.5.10/"&gt;Solidity documentation.&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;a href="https://github.com/jpmorganchase/cakeshop"&gt;Cakeshop&lt;/a&gt;
&lt;/h3&gt;

&lt;p&gt;Cakeshop lets you manage a local blockchain node.&lt;/p&gt;

&lt;p&gt;It comes with APIs and tools which you can use to set up the cluster node, work with contracts, and explore the chain.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;a href="https://github.com/ethereum/go-ethereum/wiki/geth"&gt;Geth&lt;/a&gt;
&lt;/h3&gt;

&lt;p&gt;Geth is Ethereum node implementation. It is created using the Go programming language. Geth is used in a variety of tasks on the Ethereum blockchain.&lt;/p&gt;

&lt;p&gt;It can be used to transfer tokens, mine ether tokens, and even create smart contracts. Furthermore, it can also be used to explore block history.&lt;/p&gt;

&lt;p&gt;Geth is available in the three interfaces including:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;JSON-RPC  server&lt;/li&gt;
&lt;li&gt;Command-line&lt;/li&gt;
&lt;li&gt;Interactive console&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;As a blockchain developer, you can use Geth on all three major operating systems, i.e., Windows, Mac, and Linux. &lt;/p&gt;

&lt;p&gt;Once you install Geth, you need to either connect to an existing blockchain or create your own. To simplify things, Geth automatically connects to Ethereum mainnet.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Warning:&lt;/strong&gt; Geth downloads whole Ethereum blockchain before you can start using it. Depending on your internet speed connection, it can take a while! We also recommend using an external hard disk to store Ethereum blockchain.&lt;/p&gt;

&lt;h3&gt;
  
  
  Blockchain Testnet
&lt;/h3&gt;

&lt;p&gt;As a blockchain developer, you will always need a blockchain testnet. &lt;/p&gt;

&lt;p&gt;It is an essential tool as it lets you test your dApps before making them live.&lt;/p&gt;

&lt;p&gt;Each blockchain solution has its testnet, and we recommend that you use the respective testnet. &lt;/p&gt;

&lt;p&gt;Testnets are especially useful as it lets you test without spending real resources. Ethereum, for example, uses gas as the fuel for carrying out different actions. It is not possible for developers to spend gas every time they do a test run. This means spending thousands of dollars to test. It is not feasible.&lt;/p&gt;

&lt;p&gt;A testnet lets blockchain developer iron out bugs without spending tons of cash. The choice of testnet depends on your dApp. You can use public test, private test, or GanachiCLI - a customizable blockchain emulator.&lt;/p&gt;

&lt;h3&gt;
  
  
  Blockchain-as-a-Service(BaaS)
&lt;/h3&gt;

&lt;p&gt;Implementing a full end-to-end blockchain solution is not practical for any business out there. This gave rise to Blockchain-as-a-Service(BaaS).&lt;/p&gt;

&lt;p&gt;With BaaS, businesses can create and host their dApp solution on cloud infrastructure. They have to pay for using BaaS. Moreover, they also need to hire blockchain developers to take care of all the implementation process.&lt;/p&gt;

&lt;p&gt;As a blockchain developer, you should know how to work with BaaS. it can help you gain more trust and reputation. It is similar to Software as a Service(SaaS) model.&lt;/p&gt;

&lt;p&gt;Few examples of BaaS solutions that you should know include &lt;a href="https://azure.microsoft.com/en-in/solutions/blockchain/"&gt;Azure&lt;/a&gt;, Microsoft, and SAP.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;a href="https://github.com/trufflesuite/truffle"&gt;Truffle&lt;/a&gt;
&lt;/h3&gt;

&lt;p&gt;Truffle is Ethereum blockchain framework. It offers asset pipeline and development environment for Ethereum development.&lt;/p&gt;

&lt;p&gt;With Truffle, you can develop complex Ethereum dApps and smart contracts. It has a vast library that let you tackle challenging requirements.&lt;/p&gt;

&lt;p&gt;The key features offered by Truffle include the following:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Automate contract testing using Chai and Mocha&lt;/li&gt;
&lt;li&gt;Do full smart contract development including linking, compilation, and deployment&lt;/li&gt;
&lt;li&gt;Do custom build procedures with the configurable build pipeline&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;And much more!&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;a href="https://docs.ethers.io/ethers.js/html/"&gt;Ether.js&lt;/a&gt;
&lt;/h3&gt;

&lt;p&gt;Ether.js is a handy tool when it comes to developing client-side JavaScript wallets. It lets you interact with Ethereum blockchain.&lt;/p&gt;

&lt;p&gt;Initially, it was only used to work with ethers.io, but now it is a full-fledged general-purpose library. &lt;/p&gt;

&lt;p&gt;The key feature of Ether.js includes the following:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Keep private keys safe in client&lt;/li&gt;
&lt;li&gt;Connect easily to Ethereum nodes using MetaMask, Etherscan, and other tools.&lt;/li&gt;
&lt;li&gt;Small in size, 88kb compressed.&lt;/li&gt;
&lt;li&gt;Offers great documentation&lt;/li&gt;
&lt;li&gt;Open-source (comes with MIT License)&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  &lt;a href="https://remix.ethereum.org/#optimize=false&amp;amp;evmVersion=null"&gt;Remix IDE&lt;/a&gt;
&lt;/h3&gt;

&lt;p&gt;Remix IDE is a popular IDE that runs from the browser. It lets you develop Solidity contracts from the browser.&lt;/p&gt;

&lt;p&gt;It is developed using JavaScript which means that you can use any modern browser. You can also use it locally. It comes with module support that brings more functionality to the IDE.&lt;/p&gt;

&lt;p&gt;For example, you can use a file explorer module to save or load files from your computer. Other useful modules include plugin manager, solidity editor, terminal and settings. &lt;/p&gt;

&lt;p&gt;They also have &lt;a href="https://remix-ide.readthedocs.io/en/latest/"&gt;excellent documentation.&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;a href="https://github.com/hyperledger/caliper"&gt;Hyperledger Caliper&lt;/a&gt;
&lt;/h3&gt;

&lt;p&gt;Hyperledger Caliper lets you check the blockchain performance. &lt;/p&gt;

&lt;p&gt;It can determine blockchain performance using different parameters including latency, success rate, resource consumption, and throughput.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;a href="https://www.npmjs.com/package/solc"&gt;Solc&lt;/a&gt;
&lt;/h3&gt;

&lt;p&gt;If you have used Solidity, you already know its syntax is similar to ECMAScript as it is a loosely-typed language. But, Ethereum Virtual Machine uses a slightly different format which makes Solc a must-have tool for Ethereum related projects.&lt;/p&gt;

&lt;p&gt;Solc is a Solidity compiler that covers solidity script into a more readable format. Its popularity can also be gauged from the fact that it comes natively with most of the Ethereum nodes. &lt;/p&gt;

&lt;p&gt;Solc can also be used for offline compiling.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;a href="http://dappboard.com/"&gt;dAppBoard&lt;/a&gt;
&lt;/h3&gt;

&lt;p&gt;If you want to ease your Ethereum development, then check out dAppBoard. It is an analytical platform used for Ethereum smart contracts. Moreover, it also comes with Ethereum blockchain explorer.&lt;/p&gt;

&lt;p&gt;dAppBoard is web-based and let you monitor smart contracts running on Ethereum networks. It can give you information such as a total number of users for a particular dApp or get an overview of the whole Ethereum network.&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;This leads us to the end of our best tools for blockchain development. As a developer, you should always be on the outlook for new tools. The best way to do so is to watch other developers &lt;a href="https://www.education-ecosystem.com/projects/cryptocurrency"&gt;develop interesting things.&lt;/a&gt; This way, you can learn which tool can work for you.&lt;/p&gt;

&lt;p&gt;Are you excited to try out new tools? Let us know in the comment section below.&lt;/p&gt;

&lt;p&gt;Also, published on &lt;a href="https://dzone.com/articles/11-best-tools-for-blockchain-development"&gt;Dzone&lt;/a&gt;&lt;/p&gt;

</description>
      <category>blockchain</category>
      <category>productivity</category>
    </item>
    <item>
      <title>How WordPress Security Team Protects WordPress Core</title>
      <dc:creator>Dr. Michael Garbade</dc:creator>
      <pubDate>Thu, 04 Jul 2019 18:44:55 +0000</pubDate>
      <link>https://forem.com/educationecosystem/how-wordpress-security-team-protects-wordpress-core-5d47</link>
      <guid>https://forem.com/educationecosystem/how-wordpress-security-team-protects-wordpress-core-5d47</guid>
      <description>&lt;p&gt;Have you ever wondered what makes WordPress secure? If you do, then we got you covered as we will go through how WordPress Security works.&lt;/p&gt;

&lt;p&gt;WordPress is the number one content management system. But, that also makes it the number one target for hackers.&lt;/p&gt;

&lt;p&gt;Jpolansky, a cybersecurity expert from the United States, also thinks on similar lines. His work surrounds on &lt;a href="https://www.education-ecosystem.com/jpolansky/l9kjy-how-to-perform-network-analysis-using-wireshark-snort-and-so/Lp5gG-how-to-perform-network-analysis-using-wireshark-sn/"&gt;network monitoring&lt;/a&gt;, which focuses on how to understand network data and threats identity. According to him, WordPress’s popularity is what makes it an ideal hackers target, and it is the job of the WordPress security team and ethical hackers to find the loopholes and fix them!&lt;/p&gt;

&lt;h3&gt;
  
  
  Is WordPress Insecure?
&lt;/h3&gt;

&lt;p&gt;WordPress is one of the most vulnerable content management systems out there. More than &lt;a href="https://www.wpwhitesecurity.com/statistics-70-percent-wordpress-installations-vulnerable/"&gt;70% of the WordPress website&lt;/a&gt; has some form of vulnerability.&lt;/p&gt;

&lt;p&gt;However, out of the 70% infected WordPress website, only 10% are the ones that occurred due to the WordPress core weakness. On top of that, these sites are hacked because they were using old WordPress build and have not been updated to a more secure WordPress version.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--MDlYug5w--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/gdubg41nju6p97005gu3.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--MDlYug5w--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/gdubg41nju6p97005gu3.png" alt=""&gt;&lt;/a&gt;&lt;br&gt;
Source: wpwhitesecurity.com&lt;/p&gt;

&lt;p&gt;Most of the hacks are zero-day exploits which are fixed by the WordPress team as soon as they come out. &lt;/p&gt;

&lt;p&gt;The hacks also happen because the site uses bad themes, plugins, or hosting. Even the careless end user can make their site insecure and make it vulnerable to hackers. &lt;/p&gt;

&lt;p&gt;In short, WordPress is not secure. The reason behind it is its ecosystem. It is the cumulation of different aspects, including users, plugins, and themes, which means the majority of WordPress websites are vulnerable.&lt;/p&gt;

&lt;h3&gt;
  
  
  Security Releases
&lt;/h3&gt;

&lt;p&gt;The &lt;a href="https://wordpress.org/news/category/security/"&gt;WordPress release cycle&lt;/a&gt; is at the core of improving WordPress with each release. &lt;/p&gt;

&lt;p&gt;It starts with the formation of the core team and then discussing features. Once the features are decided upon, they move to the development phase. Next, they release betas to test out the build and find out any bugs associated with it. The release candidate is then followed by the launch.&lt;/p&gt;

&lt;p&gt;WordPress version numbering determines if it is a major release or a security release.&lt;/p&gt;

&lt;p&gt;All major releases start with first two number sequence. So, that means that 5.0, 4.9, 3.5, etc. are all major releases.&lt;/p&gt;

&lt;p&gt;However, the minor releases are aimed to provide critical bugs and vulnerabilities fixes.&lt;/p&gt;

&lt;p&gt;So, what does that mean for a WordPress user? Not only they have to update to major releases, but also keep updating to the minor releases as well. The minor releases are aimed at security and should not be ignored at any cost. Security releases are pushed automatically to WordPress website if they are not turned off by the admin itself.&lt;/p&gt;

&lt;h3&gt;
  
  
  Role of WordPress Security Team
&lt;/h3&gt;

&lt;p&gt;So, who keeps WordPress core safe from all the vulnerabilities and hacks? It is the “WordPress Security Team.”&lt;/p&gt;

&lt;p&gt;The security team consists of approx 50 experts - a group of security researchers and lead developers. Their work is to collaborate with other security teams all around the world, and ensure that they fix the vulnerabilities before it is exploited by hackers.&lt;/p&gt;

&lt;p&gt;The security team is proactive in their approach and always ensure that potential vulnerabilities are put forward and fixed as soon as possible. &lt;/p&gt;

&lt;h3&gt;
  
  
  How secure is the WordPress core?
&lt;/h3&gt;

&lt;p&gt;Over the years, WordPress has seen many major and minor releases. &lt;/p&gt;

&lt;p&gt;WordPress follows the OWASP to ensure that WordPress maintains the same level of security.&lt;/p&gt;

&lt;p&gt;OWASP is the Open Web Application Security Project for web application security. It is a community-driven and extremely comprehensive.&lt;/p&gt;

&lt;p&gt;The top 10 OWASP threats have been covered and secure in WordPress. They include the following.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Injection&lt;/li&gt;
&lt;li&gt;Session Management and Broken Authentication&lt;/li&gt;
&lt;li&gt;Cross-Site Scripting(XSS)&lt;/li&gt;
&lt;li&gt;Insecure Direct Object Reference&lt;/li&gt;
&lt;li&gt;Sensitive Data Exposure&lt;/li&gt;
&lt;li&gt;Security Misconfiguration&lt;/li&gt;
&lt;li&gt;Missing Function Level Access Control&lt;/li&gt;
&lt;li&gt;Known Vulnerabilities for using components&lt;/li&gt;
&lt;li&gt;Cross-Site Request Forgery(CSRF)&lt;/li&gt;
&lt;li&gt;Unvalidated Forwards and Redirects.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Apart from the top 10 threats, other security concerns are also handled by OWASP. As a WordPress user, you should not worry about the major vulnerabilities at all. &lt;/p&gt;

&lt;p&gt;If you fancy yourself to help WordPress security, you should learn about Ethical Hacking Basics. You can get the &lt;a href="https://www.education-ecosystem.com/darrenrainey/RG7am-ethical-hacking-basics/KpmNL-ethical-hacking-basics/"&gt;basics of ethical hacking&lt;/a&gt; and grow yourself as a security expert -- and maybe one day help secure WordPress core!&lt;br&gt;
WordPress Security as a process&lt;br&gt;
WordPress ecosystem is huge. It consists of plugins and themes, developed by countless third-party developers. The quality of the code of the plugin and themes also determine whether your site is secure or not.&lt;/p&gt;

&lt;p&gt;As an administrator, you need to &lt;a href="https://www.wpbeginner.com/wordpress-security/"&gt;secure your website&lt;/a&gt; correctly. You can also use Sucuri, WordFence, and BulletProof plugins to automate most of the security of the site. These plugins or services provide WordPress security as a process. WordPress security is a huge topic, and many companies working hard to secure your website!&lt;/p&gt;

&lt;h3&gt;
  
  
  What’s next?
&lt;/h3&gt;

&lt;p&gt;WordPress security is essential for all the users and the web itself. If it stays secure, then most of the internet stays secure, considering that 30% of the online websites are developed using it.&lt;/p&gt;

&lt;p&gt;So, what do you think about WordPress security?&lt;/p&gt;

&lt;p&gt;Comment below and let us know.&lt;/p&gt;

</description>
      <category>wordpress</category>
      <category>wordpresscore</category>
      <category>wordpresssecurity</category>
    </item>
    <item>
      <title>3 Ways to Create Objects in Object-Oriented JavaScript</title>
      <dc:creator>Dr. Michael Garbade</dc:creator>
      <pubDate>Thu, 04 Oct 2018 19:41:46 +0000</pubDate>
      <link>https://forem.com/educationecosystem/3-ways-to-create-objects-in-object-oriented-javascript-18nl</link>
      <guid>https://forem.com/educationecosystem/3-ways-to-create-objects-in-object-oriented-javascript-18nl</guid>
      <description>&lt;p&gt;(This article was originally published on my blog &lt;a href="https://blog.liveedu.tv/3-ways-to-create-objects-in-object-oriented-javascript/"&gt;here&lt;/a&gt; ).&lt;/p&gt;

&lt;p&gt;JavaScript is a powerful programming language that supports Object Oriented Programming (OOP). &lt;/p&gt;

&lt;p&gt;In fact, in JavaScript, objects rule the day—from core features such as strings and arrays to browser APIs built using the language.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.liveedu.tv/bautistaaa/lm4jx-how-to-build-a-simple-slack-clone-in-firebase-and-angularjs/w1Nzx-how-to-build-chatroom-web-app-like-slack-in-angu-9/"&gt;Bautista&lt;/a&gt;, a U.S.-based web developer who is passionate at teaching people about programming, emphasizes that “to take your JavaScript skills to the next level, you need to understand the object-based nature of the language.”  &lt;/p&gt;

&lt;p&gt;Here are three ways to create objects in Object-Oriented JavaScript (OOJS) programming:&lt;/p&gt;

&lt;h1&gt;
  
  
  1. Using object literals
&lt;/h1&gt;

&lt;p&gt;In OOP, an object literal refers to a comma-split list of name-value pairs enclosed within curly brackets.&lt;/p&gt;

&lt;p&gt;The names are strings, and the values are any primitive data types available in JavaScript such as arrays, strings, numbers, functions, and many others.&lt;/p&gt;

&lt;p&gt;Usually, object literals are utilized in encapsulating code and wrapping it in an orderly package. This way, they prevent collisions with variables and objects found on the global scope.&lt;/p&gt;

&lt;p&gt;With object literals, you can gather properties and methods together and make your code clean and uncluttered.&lt;/p&gt;

&lt;p&gt;Here is an example:&lt;/p&gt;



&lt;div class="highlight"&gt;&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;liveedu&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="c1"&gt;//declaring properties&lt;/span&gt;
&lt;span class="na"&gt;student&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;james&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="c1"&gt;//declaring methods&lt;/span&gt;
&lt;span class="na"&gt;watch&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;learn new tech skills&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="p"&gt;},&lt;/span&gt;
&lt;span class="p"&gt;};&lt;/span&gt;
&lt;span class="c1"&gt;//accessing methods and properties&lt;/span&gt;
&lt;span class="nx"&gt;liveedu&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;watch&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;span class="c1"&gt;//output is learn new tech skills&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;JavaScript object literals are singletons, and they allow you to create objects conveniently and flexibly. &lt;/p&gt;

&lt;p&gt;They save you from writing excessive lines of code.&lt;/p&gt;

&lt;p&gt;For example, you can place an object literal anywhere in your workspace without including any previous setup, and it will still work well—something which can be very useful!&lt;/p&gt;

&lt;p&gt;Although object literals are important, they do not support instantiation or inheritance. &lt;/p&gt;

&lt;p&gt;If you want to make use of these features, you’ll need to use other techniques for creating objects. &lt;/p&gt;

&lt;h1&gt;
  
  
  2. Using object constructor functions
&lt;/h1&gt;

&lt;p&gt;Constructor functions are the most conventional technique of creating &lt;a href="https://developer.mozilla.org/en-US/docs/Learn/JavaScript/Objects/Object_prototypes"&gt;JavaScript objects&lt;/a&gt; that rely on prototyping inheritance to utilize each other’s functionalities.&lt;/p&gt;

&lt;p&gt;A key characteristic of these functions is that they can be instantiated and inherited from.&lt;/p&gt;

&lt;p&gt;Let’s see an example of how constructor functions can be used in OOJS.&lt;/p&gt;



&lt;div class="highlight"&gt;&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nx"&gt;Liveedu&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;student&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;

      &lt;span class="c1"&gt;// properties&lt;/span&gt;

    &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;student&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;student&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

    &lt;span class="c1"&gt;// methods&lt;/span&gt;

    &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;watch&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;

      &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;student&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;learns new tech skills&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="c1"&gt;// instantiating the object&lt;/span&gt;

&lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;liveedu&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nx"&gt;Liveedu&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;James &lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="c1"&gt;// accessing methods and properties&lt;/span&gt;

&lt;span class="nx"&gt;liveedu&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;watch&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt; &lt;span class="c1"&gt;//output is James learns new tech skills&lt;/span&gt;

&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;Object&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;getPrototypeOf&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;liveedu&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt; &lt;span class="c1"&gt;// output is object&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Here is what is happening on the above code:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Constructor functions are created just like regular functions. However, the difference is that the &lt;em&gt;this&lt;/em&gt; keyword is employed for declaring properties and methods. In this case, &lt;em&gt;this&lt;/em&gt; represents the object presently in the scope of the &lt;em&gt;Liveedu&lt;/em&gt; function. &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;A new object referred to as &lt;em&gt;liveedu&lt;/em&gt; is created using the &lt;em&gt;new&lt;/em&gt; operator. Typically, &lt;em&gt;new&lt;/em&gt; binds the newly created object to the &lt;em&gt;this&lt;/em&gt; operator within the called constructor function. Consequently, the binding enables the &lt;em&gt;liveedu&lt;/em&gt; object to acquire the properties and methods of the constructor function. &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The &lt;em&gt;liveedu&lt;/em&gt; object has a property referred to as &lt;em&gt;prototype&lt;/em&gt;, which is where all inherited members are defined. So, when a function like &lt;em&gt;watch()&lt;/em&gt; is called, the browser will move up the chain of objects and their respective prototype properties until it retrieves its value.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h1&gt;
  
  
  3. Using prototyping inheritance
&lt;/h1&gt;

&lt;p&gt;JavaScript objects can also be created using the concept of prototypical inheritance. &lt;/p&gt;

&lt;p&gt;Most modern browsers implement prototypes using a special property called &lt;strong&gt;proto&lt;/strong&gt;, which is pronounced as &lt;em&gt;dunder proto&lt;/em&gt; (shortened version of double underscore prototype).&lt;/p&gt;

&lt;p&gt;Let’s use the following examples to illustrate how &lt;strong&gt;proto&lt;/strong&gt; can be used in prototyping inheritance. &lt;/p&gt;



&lt;div class="highlight"&gt;&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;liveedu&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; 

    &lt;span class="na"&gt;student&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;james&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;

    &lt;span class="na"&gt;watch&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;

        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;student&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt; is learning new skills&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;livecoding&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; 

    &lt;span class="na"&gt;student&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;felix&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;

    &lt;span class="na"&gt;watch&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;

        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;student&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt; is learning new skills&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;As you can see on the above code, both objects have similar methods, which make the code look redundant. &lt;/p&gt;

&lt;p&gt;Therefore, to make the objects share the same &lt;em&gt;watch&lt;/em&gt; method, we can use the &lt;strong&gt;proto&lt;/strong&gt; prototype property. &lt;/p&gt;

&lt;p&gt;In other words, we can use the prototype to extend the properties of the objects.&lt;/p&gt;

&lt;p&gt;Here’s is the rewrite of the above code:&lt;/p&gt;



&lt;div class="highlight"&gt;&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;WatchProto&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;

    &lt;span class="na"&gt;watch&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;

        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;student&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt; is learning new skills&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;liveedu&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; 

    &lt;span class="na"&gt;student&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;james&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;

    &lt;span class="na"&gt;__proto__&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;WatchProto&lt;/span&gt;

&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;livecoding&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; 

    &lt;span class="na"&gt;student&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;felix&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;

    &lt;span class="na"&gt;__proto__&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;WatchProto&lt;/span&gt;

&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;liveedu&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;watch&lt;/span&gt;&lt;span class="p"&gt;());&lt;/span&gt; &lt;span class="c1"&gt;//james is learning new skills&lt;/span&gt;

&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;livecoding&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;watch&lt;/span&gt;&lt;span class="p"&gt;());&lt;/span&gt; &lt;span class="c1"&gt;//felix is learning new skills&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;As you can see on the above code, both the objects share the same method that is defined in &lt;em&gt;WatchProto&lt;/em&gt;. The &lt;em&gt;liveedu&lt;/em&gt; and &lt;em&gt;livecoding&lt;/em&gt; objects can directly access it, leading to cleaner and efficient code. &lt;/p&gt;

&lt;p&gt;It’s important to note that &lt;strong&gt;proto&lt;/strong&gt; is a new JavaScript ES6 syntax that may not be available in old browsers. &lt;/p&gt;

&lt;p&gt;Alternatively, you can use the &lt;em&gt;Object.create()&lt;/em&gt; method to create prototypes.&lt;/p&gt;

&lt;p&gt;Here is an example:&lt;/p&gt;



&lt;div class="highlight"&gt;&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;WatchProto&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;

    &lt;span class="na"&gt;watch&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;

        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;student&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt; is learning new skills&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;liveedu&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;Object&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;create&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;WatchProto&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="nx"&gt;liveedu&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;student&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;james&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h1&gt;
  
  
  Wrapping up
&lt;/h1&gt;

&lt;p&gt;Understanding JavaScript objects is key to getting deeper into the ubiquitous language.&lt;/p&gt;

&lt;p&gt;What’s your experience with implementing the object-oriented programming features of JavaScript?&lt;/p&gt;

&lt;p&gt;Please share your comments and questions below. &lt;/p&gt;

</description>
      <category>objects</category>
      <category>objectoriented</category>
      <category>javascript</category>
      <category>oop</category>
    </item>
    <item>
      <title>How to Use the HTML5 Canvas Element with JavaScript</title>
      <dc:creator>Dr. Michael Garbade</dc:creator>
      <pubDate>Wed, 19 Sep 2018 21:26:57 +0000</pubDate>
      <link>https://forem.com/educationecosystem/how-to-use-the-html5-canvas-element-with-javascript-267n</link>
      <guid>https://forem.com/educationecosystem/how-to-use-the-html5-canvas-element-with-javascript-267n</guid>
      <description>&lt;p&gt;(This article was originally published on my blog &lt;a href="https://blog.liveedu.tv/how-to-use-the-html5-canvas-element-with-javascript/" rel="noopener noreferrer"&gt;here&lt;/a&gt; ).&lt;/p&gt;

&lt;p&gt;Before HTML5 was introduced into the world of web developers, things were lifeless, unsatisfying, and complicated to achieve. For instance, any developer who needed to create graphics and animations was forced to depend on tools like Flash plugin or Java plugin—something which was burdensome and head spinning. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.liveedu.tv/nikitka/ZnKNw-space-shootem-up-game-in-html5-and-js/1krXV-introduction/" rel="noopener noreferrer"&gt;Nikitka&lt;/a&gt;, who has more than seven years of web development experience and currently teaches people his skills, says that “the advent of the powerful HTML5 element called Canvas turned around things and empowered developers to complete actions that were previously difficult.”&lt;/p&gt;

&lt;h2&gt;
  
  
  What is HTML5 Canvas?
&lt;/h2&gt;

&lt;p&gt;Canvas is an HTML5 element that allows you to easily and powerfully draw graphics, on the fly, using the ubiquitous JavaScript programming language. &lt;/p&gt;

&lt;p&gt;The &lt;strong&gt;&lt;/strong&gt; element only works as a container for graphics; therefore, you should use JavaScript to render the graphics.&lt;/p&gt;

&lt;p&gt;You can use the Canvas element to achieve various objectives on your web applications, including drawing graphs, creating HTML Canvas animations, developing games, or creating photos—all without depending on another external tool.&lt;/p&gt;

&lt;p&gt;Amazingly, Canvas is available as an API, and it is supported by most modern browsers and platforms. Furthermore, it’s cross-platform compatible. As such you can create an application once, and deploy it anywhere—on PCs or mobile devices.&lt;/p&gt;

&lt;h2&gt;
  
  
  Let’s see a Canvas markup code
&lt;/h2&gt;

&lt;p&gt;Here is a simple markup for the HTML5 Canvas element:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;canvas&lt;/span&gt; &lt;span class="nx"&gt;width&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;320&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="nx"&gt;height&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;160&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="nx"&gt;id&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;canvasExample&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/canvas&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;As you can see on the above code, the Canvas element allows two specific attributes: &lt;strong&gt;width&lt;/strong&gt; and &lt;strong&gt;height&lt;/strong&gt;. If you do not provide values for these two attributes, the Canvas will resort to its default values of 300 pixels for width and 150 pixels for height. &lt;/p&gt;

&lt;p&gt;The &lt;strong&gt;id&lt;/strong&gt; attribute is used for identifying the Canvas element in the JavaScript code. Furthermore, you can include other CSS styling properties to make the canvas drawing region more interactive and visible, such as padding, background color, or border—just like with any other HTML element.&lt;/p&gt;

&lt;h2&gt;
  
  
  How to draw on a Canvas
&lt;/h2&gt;

&lt;p&gt;To create graphics on a Canvas, you need to begin by targeting it using the Document Object Model (DOM).&lt;/p&gt;

&lt;p&gt;And, an &lt;strong&gt;id&lt;/strong&gt; attribute will assist you to identify the matching target location (in this HTML Canvas example, the id is “canvasExample”).&lt;/p&gt;

&lt;p&gt;Initially, the  element is blank. Thus, to exhibit something, a JavaScript script should obtain the rendering context before drawing on it. &lt;/p&gt;

&lt;p&gt;The Canvas element has an in-built DOM method referred to as &lt;strong&gt;getContext&lt;/strong&gt;. It is a JavaScript function utilized in accessing the rendering context together with its drawing methods. This function accepts a single parameter, which is usually the 2D graphics context (defined as “2d”).&lt;/p&gt;

&lt;h2&gt;
  
  
  Example of JavaScript Canvas Code
&lt;/h2&gt;

&lt;p&gt;For example, to create a rectangle shape on the Canvas, you’ll need the following property and functions:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;fillStyle = “color”&lt;/strong&gt;—it adds color to the shape; otherwise, it will have a default color of black
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;fillRect(x,y,width,height)&lt;/strong&gt;—it draws a filled rectangle &lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;strokeRect(x,y,width,height)&lt;/strong&gt;—it gives the rectangle its outline &lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;clearRect(x,y,width,height)&lt;/strong&gt;—it clears the specified rectangular section and makes it entirely transparent &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;For defining coordinates, the Canvas grid or coordinate system is used. In this system, the original dimensions are located on the upper-left corner of the Canvas region, at coordinate (0,0). *&lt;/p&gt;

&lt;p&gt;As such, the X coordinate will be moving to the right whereas the Y coordinate will be moving downwards. The distance is in pixels.&lt;/p&gt;

&lt;p&gt;Here is an image showing how the Canvas Grid system works:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fe9cdv3asq2ybz3lgk3uv.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fe9cdv3asq2ybz3lgk3uv.png" alt="Canvas grid system" width="498" height="286"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Each of the above-mentioned functions for creating rectangles takes the following parameters for denoting the coordinates and dimensions:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;x gives the horizontal position from the upper-left corner to the right &lt;/li&gt;
&lt;li&gt;y gives the vertical position from the top-left corner to the bottom &lt;/li&gt;
&lt;li&gt;width gives the width of the rectangle &lt;/li&gt;
&lt;li&gt;height gives the height of the rectangle &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Here is a JavaScript canvas tutorial example code that draws a rectangle:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="o"&gt;&amp;lt;!&lt;/span&gt;&lt;span class="nx"&gt;DOCTYPE&lt;/span&gt; &lt;span class="nx"&gt;html&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;html&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;head&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;title&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="nx"&gt;JavaScript&lt;/span&gt; &lt;span class="nx"&gt;HTML5&lt;/span&gt; &lt;span class="nx"&gt;Canvas&lt;/span&gt; &lt;span class="nx"&gt;Example&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/title&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/head&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;body&lt;/span&gt; &lt;span class="nx"&gt;onload&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;canvasExample()&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;canvas&lt;/span&gt; &lt;span class="nx"&gt;width&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;320&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="nx"&gt;height&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;160&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="nx"&gt;id&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;canvasExample&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/canvas&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;script&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;canvasExample&lt;/span&gt;&lt;span class="p"&gt;(){&lt;/span&gt;
        &lt;span class="c1"&gt;//identify the Canvas element via the DOM&lt;/span&gt;
        &lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;canvas&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getElementById&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;canvasExample&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
        &lt;span class="c1"&gt;//checking for Canvas browser compatibility&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;canvas&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;getContext&lt;/span&gt;&lt;span class="p"&gt;){&lt;/span&gt;
            &lt;span class="c1"&gt;//Use getContext to specify the rendering context&lt;/span&gt;
            &lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;context&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;canvas&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getContext&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;2d&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
            &lt;span class="c1"&gt;//setting of color&lt;/span&gt;
            &lt;span class="nx"&gt;context&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;fillStyle&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;blue&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
            &lt;span class="c1"&gt;//creating the rectangle&lt;/span&gt;
            &lt;span class="nx"&gt;context&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;fillRect&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;50&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;50&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;150&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;250&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
            &lt;span class="nx"&gt;context&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;clearRect&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;75&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;75&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;100&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;50&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
            &lt;span class="nx"&gt;context&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;strokeRect&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;90&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;90&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;75&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;20&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

        &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="k"&gt;else&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="c1"&gt;//providing a fallback option&lt;/span&gt;
            &lt;span class="nf"&gt;alert&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Please a Canvas-Supporting Web Browser&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
        &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/script&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/body&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/html&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here is the output on a browser:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fz1ebsotpym8nruvy7ir8.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fz1ebsotpym8nruvy7ir8.png" alt="Canvas element" width="299" height="199"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This is what is happening in the JavaScript script:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The Canvas element is first identified through the DOM
&lt;/li&gt;
&lt;li&gt;The context is defined &lt;/li&gt;
&lt;li&gt;The fillRect() function produces a rectangle of 150 by 250 pixels &lt;/li&gt;
&lt;li&gt;The clearRect() function then deletes a rectangle of 100 by 50 pixels from the center &lt;/li&gt;
&lt;li&gt;Lastly, strokeRect() function constructs a rectangle of 75 by 20 pixels within the cleared region &lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Wrapping up
&lt;/h2&gt;

&lt;p&gt;As demonstrated by this HTML5 Canvas example, this element allows you to use JavaScript to dynamically render graphics on the web browser. &lt;/p&gt;

&lt;p&gt;Canvas is great because it is completely open sourced, highly interactive, and very flexible. It’s what you need to add some life to your applications and accelerate their performance.&lt;/p&gt;

&lt;p&gt;Therefore, you need to &lt;a href="https://www.liveedu.tv/guides/programming/javascript/" rel="noopener noreferrer"&gt;learn how it works&lt;/a&gt; and take your web development skills to the next level.&lt;/p&gt;

&lt;p&gt;All the best.&lt;/p&gt;

</description>
      <category>html</category>
      <category>javascript</category>
      <category>canvas</category>
    </item>
    <item>
      <title>3 Best Practices for Working With React Components</title>
      <dc:creator>Dr. Michael Garbade</dc:creator>
      <pubDate>Thu, 06 Sep 2018 19:34:39 +0000</pubDate>
      <link>https://forem.com/educationecosystem/3-best-practices-for-working-with-react-components-3j44</link>
      <guid>https://forem.com/educationecosystem/3-best-practices-for-working-with-react-components-3j44</guid>
      <description>&lt;p&gt;(This article was originally published on our blog &lt;a href="https://blog.liveedu.tv/3-best-practices-for-working-with-react-components/"&gt;here&lt;/a&gt; ). &lt;/p&gt;

&lt;p&gt;&lt;a href="https://reactjs.org/"&gt;React.js&lt;/a&gt; (also referred to as ReactJS or React) is a popular JavaScript library for creating wonderful user interfaces. &lt;/p&gt;

&lt;p&gt;One of the notable features of React is that it relies on a component-focused approach for building interactive UIs.   &lt;/p&gt;

&lt;p&gt;Maxim-Filimonov, who has more than ten years of experience in the software development industry and presently teaches people his skills, says that “adhering to the React API best practices when creating components will assist you to write high-quality and clean React code.”&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.liveedu.tv/maxim-filimonov/2b1rr-how-to-build-cross-platform-mobile-app-in-react-native/gYoKx-intro-video1/"&gt;Click here&lt;/a&gt; to watch and learn from one of his projects on How to Build Cross-platform Mobile App in React Native. &lt;/p&gt;

&lt;p&gt;Here are three React tips and best practices you need to take your development skills a notch higher.&lt;/p&gt;

&lt;h2&gt;
  
  
  1. Avoid creating new components unnecessarily
&lt;/h2&gt;

&lt;p&gt;Here is an example of a React component:&lt;/p&gt;



&lt;div class="highlight"&gt;&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="k"&gt;default&lt;/span&gt; &lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nx"&gt;Liveedu&lt;/span&gt; &lt;span class="kd"&gt;extends&lt;/span&gt; &lt;span class="nx"&gt;PureComponent&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;static&lt;/span&gt; &lt;span class="nx"&gt;propTypes&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="na"&gt;userIsLearning&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;PropTypes&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;bool&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;user&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;PropTypes&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;shape&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
      &lt;span class="na"&gt;_id&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;PropTypes&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;string&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="p"&gt;}).&lt;/span&gt;&lt;span class="nx"&gt;isNeeded&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;

  &lt;span class="kd"&gt;static&lt;/span&gt; &lt;span class="nx"&gt;defaultProps&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="na"&gt;userIsLearning&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;

  &lt;span class="nx"&gt;render&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;userIsLearning&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;user&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;props&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="nx"&gt;userIsLearning&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;Learning&lt;/span&gt; &lt;span class="o"&gt;/&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;
      &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;div&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
        &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;div&lt;/span&gt; &lt;span class="nx"&gt;className&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;two-col&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
          &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;section&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
            &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;LearnOnline&lt;/span&gt; &lt;span class="nx"&gt;userId&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;user&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;id&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="sr"&gt;/&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;            &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;Watching&lt;/span&gt; &lt;span class="nx"&gt;projects&lt;/span&gt; &lt;span class="nx"&gt;userId&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;user&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;_id&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="sr"&gt;/&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;          &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/section&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;          &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;aside&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
            &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;UserDetails&lt;/span&gt; &lt;span class="nx"&gt;user&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;user&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="sr"&gt;/&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;            &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;WatchProjects&lt;/span&gt; &lt;span class="nx"&gt;user&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;user&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="sr"&gt;/&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;          &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/aside&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;        &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/div&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;        &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;div&lt;/span&gt; &lt;span class="nx"&gt;className&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;one-col&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
          &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;isInfo&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;student&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;user&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;user&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;_id&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt;
            &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;LearnersInfo&lt;/span&gt; &lt;span class="nx"&gt;userId&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;user&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;_id&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="sr"&gt;/&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;          &lt;span class="p"&gt;}&lt;/span&gt;
        &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/div&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;      &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/div&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;    &lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;As you can see from the above code, we have a single component called &lt;em&gt;Liveedu&lt;/em&gt;. We’ve included other components like &lt;em&gt;LearnOnline&lt;/em&gt; and &lt;em&gt;WatchProjects&lt;/em&gt; inside this huge component.&lt;/p&gt;

&lt;p&gt;Since we are taking all the data from the same location (&lt;em&gt;user&lt;/em&gt;), we could have just declared the components separately. However, to achieve conciseness, we opted to include the smaller components inside one component.&lt;/p&gt;

&lt;p&gt;Whereas there are no black and white rules concerning how to create a new component for your React code, the following guidelines are worthwhile:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;If you are going to reuse your code, consider creating new components for each functionality. &lt;/li&gt;
&lt;li&gt;If you want each component to represent a specific functionality, then making new components can be a good idea. &lt;/li&gt;
&lt;li&gt;If your code is becoming unwieldy and cluttered, improve readability by creating new components. &lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  2. Know when to use Component, Stateless Functional Component, and PureComponent
&lt;/h2&gt;

&lt;p&gt;Another best practice when creating React code is to know when to use the various types of components.&lt;/p&gt;

&lt;p&gt;Here is a code sample that shows how to create a Stateless Functional Component:&lt;/p&gt;



&lt;div class="highlight"&gt;&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;Liveedu&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;
  &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;WatchProjects&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;H1&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="nx"&gt;Programming&lt;/span&gt; &lt;span class="nx"&gt;Projects&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/H1&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;    &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;div&lt;/span&gt; &lt;span class="nx"&gt;className&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;learn_online&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
      &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;Link&lt;/span&gt; &lt;span class="nx"&gt;className&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;liveedu_project_image&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="nx"&gt;to&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;/&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
        &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;img&lt;/span&gt; &lt;span class="nx"&gt;alt&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;experts building projects&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="nx"&gt;src&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;liveedu.jpg&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
      &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/Link&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;      &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;div&lt;/span&gt; &lt;span class="nx"&gt;className&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Project Learning Platform&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
        &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;h2&lt;/span&gt; &lt;span class="nx"&gt;className&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;create&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="nx"&gt;Programming&lt;/span&gt; &lt;span class="nx"&gt;Projects&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/h2&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;        &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;li&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="nx"&gt;JavaScript&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/li&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;        &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;li&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="nx"&gt;PHP&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/li&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;        &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;li&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="nx"&gt;Angular&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/li&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;      &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/div&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;    &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/div&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;  &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/WatchProjects&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;This type of component will assist you to write clean and uncluttered React code. &lt;/p&gt;

&lt;p&gt;You can use them to make components that are not relying on any type of &lt;em&gt;refs&lt;/em&gt;, &lt;em&gt;state&lt;/em&gt;, or other &lt;em&gt;lifecycle methods&lt;/em&gt;. &lt;/p&gt;

&lt;p&gt;Therefore, you’ll not be concerned about state manipulation or lifecycle methods, which will not force you to install libraries for performing tests.&lt;/p&gt;

&lt;p&gt;Just like the name suggests, this component is without any state; it’s just a function. Therefore, it assists you to define a component just like a constant function that returns the required data.&lt;/p&gt;

&lt;p&gt;In other words, it is a function that is used to return JSX. &lt;/p&gt;

&lt;p&gt;In the above first code sample, you might have realized that we declared &lt;em&gt;Liveedu&lt;/em&gt; as &lt;em&gt;PureComponent&lt;/em&gt; instead of using the traditional &lt;em&gt;Component&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;PureComponent&lt;/em&gt; is often used to prevent React from re-rendering unnecessarily. Whenever a component receives a new prop, it will automatically be re-rendered. &lt;/p&gt;

&lt;p&gt;This will take place even when a component has received a new prop without any changes.&lt;/p&gt;

&lt;p&gt;For example, if a prop is referencing a string or Boolean value, and changes take place, a &lt;em&gt;PureComponent&lt;/em&gt; can detect that. &lt;/p&gt;

&lt;p&gt;On the other hand, whenever a property inside an object experiences any changes, a &lt;em&gt;PureComponent&lt;/em&gt; cannot initiate React re-rendering.&lt;/p&gt;

&lt;p&gt;Therefore, you can use &lt;em&gt;PureComponent&lt;/em&gt; in place of &lt;em&gt;Component&lt;/em&gt; to ensure re-rendering takes place only when necessary.&lt;/p&gt;

&lt;h2&gt;
  
  
  3. Use spread attributes sparingly
&lt;/h2&gt;

&lt;p&gt;The &lt;em&gt;…&lt;/em&gt; (three dots) spread operator is useful for achieving brevity in your React code. &lt;/p&gt;

&lt;p&gt;Here is a code sample that selects specific props that a component consumes and uses the spread operator to pass the entire props object&lt;/p&gt;



&lt;div class="highlight"&gt;&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;Liveedu&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;props&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;kind&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;...&lt;/span&gt;&lt;span class="nx"&gt;other&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;props&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;className&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;kind&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;primary&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="p"&gt;?&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;PrimaryButton&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;SecondaryButton&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;button&lt;/span&gt; &lt;span class="nx"&gt;className&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;className&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="p"&gt;{...&lt;/span&gt;&lt;span class="nx"&gt;other&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="sr"&gt;/&amp;gt;&lt;/span&gt;&lt;span class="err"&gt;;
&lt;/span&gt;&lt;span class="p"&gt;};&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;App&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;div&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
      &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;Button&lt;/span&gt; &lt;span class="nx"&gt;kind&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;primary&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="nx"&gt;onClick&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;clicked to start learning&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)}&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
        &lt;span class="nx"&gt;Watch&lt;/span&gt; &lt;span class="nx"&gt;Experts&lt;/span&gt; &lt;span class="nx"&gt;Create&lt;/span&gt; &lt;span class="nx"&gt;Practical&lt;/span&gt; &lt;span class="nx"&gt;Projects&lt;/span&gt;
      &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/Button&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;    &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/div&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;  &lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;};&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;In the above code, the &lt;em&gt;kind&lt;/em&gt; prop is consumed without any issues. Furthermore, it is not passed to the &lt;em&gt;&amp;lt;button&amp;gt;&lt;/em&gt; element in the Document Object Model (DOM).&lt;/p&gt;

&lt;p&gt;Also, the other props are passed using the &lt;em&gt;…other&lt;/em&gt; object, which adds some flexibility to this component. In fact, it passes an &lt;em&gt;onClick&lt;/em&gt; and &lt;em&gt;children&lt;/em&gt; props, as shown on the code.&lt;/p&gt;

&lt;p&gt;Whereas using spread attributes in your components can be beneficial, it increases the chances of passing needless props to components that do not care about their existence.&lt;/p&gt;

&lt;p&gt;Furthermore, this syntax can make you pass unwarranted HTML attributes to the DOM. &lt;/p&gt;

&lt;p&gt;Therefore, using them sparingly is better.&lt;/p&gt;

&lt;h2&gt;
  
  
  Wrapping up
&lt;/h2&gt;

&lt;p&gt;React components are the cornerstone to creating powerful and intuitive user interfaces. &lt;/p&gt;

&lt;p&gt;The above-mentioned best practices will give you the confidence you need &lt;a href="https://www.liveedu.tv/guides/programming/react-js/"&gt;to take React.js by its horns&lt;/a&gt; and escalate your front-end development skills to the next level.&lt;/p&gt;

&lt;p&gt;What other React.js best practices do you know?&lt;/p&gt;

&lt;p&gt;Please share your comments below.&lt;/p&gt;

</description>
      <category>react</category>
      <category>components</category>
      <category>programming</category>
    </item>
    <item>
      <title>iOS vs. Android Development: Which is the Best Choice for You?</title>
      <dc:creator>Dr. Michael Garbade</dc:creator>
      <pubDate>Tue, 21 Aug 2018 20:37:56 +0000</pubDate>
      <link>https://forem.com/educationecosystem/ios-vs-android-development-which-is-the-best-choice-for-you-cjm</link>
      <guid>https://forem.com/educationecosystem/ios-vs-android-development-which-is-the-best-choice-for-you-cjm</guid>
      <description>&lt;p&gt;(This article was originally published on my blog &lt;a href="http://blog.liveedu.tv/ios-vs-android-app-development-which-is-the-best-choice-for-you/"&gt;here&lt;/a&gt; ).&lt;/p&gt;

&lt;p&gt;The world of operating systems has seen the race to clinch the biggest market share tighten between two giants: iOS and Android. &lt;/p&gt;

&lt;p&gt;Asitaka, who has more than four years in Android development and currently teaches people his skills, says that “App developers are often forced to decide which platform between the two would best suits their development needs.” &lt;/p&gt;

&lt;p&gt;You can watch and learn from one of his projects &lt;a href="https://www.liveedu.tv/asitaka/2w9nx-how-to-create-simple-instagram-like-android-app-in-kotlin/"&gt;here&lt;/a&gt;. &lt;/p&gt;

&lt;p&gt;Here are three critical things that will assist you to make the best choice:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The target audience &lt;/li&gt;
&lt;li&gt;Your set budget &lt;/li&gt;
&lt;li&gt;The benefits you expect to accrue &lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  1. The Target Audience
&lt;/h3&gt;

&lt;p&gt;What are your audience’s preferences? Your audience’s behavioral patterns should guide you on the best platform to choose for your app.&lt;/p&gt;

&lt;p&gt;Currently, the Android operating system commands a bigger market share of 87% with the platform being a favorite in developing countries and among lower income earners. &lt;/p&gt;

&lt;p&gt;This can be attributed to the introduction of smartphones running on the Android OS in emerging markets for as little as $100. &lt;/p&gt;

&lt;p&gt;For a long time, the iPhones were out of reach for the low-income earners who could not afford the $600 that the devices were priced at.&lt;/p&gt;

&lt;p&gt;The proliferation of the cheaper smartphones made it affordable and accessible to more users.&lt;/p&gt;

&lt;p&gt;The Google infrastructure also plays a huge role in the popularity of smartphones by allowing users to fulfill their desires and customize their devices. For instance, the availability of different widgets and backgrounds lets users to modify and lock their home screens as they please.&lt;/p&gt;

&lt;p&gt;The iOS, on the other hand, does not command such a huge market share. The platform has a 12.82% following and it is a favorite with the younger generation who spend most of their time scouting apps. It is also popular among the educated class and those with higher income levels.&lt;/p&gt;

&lt;p&gt;In the U.S., for instance, an iPhone user makes an average of $85,000 annually while an Android user averages $61,000 in annual earnings; a 40% contrast.&lt;/p&gt;

&lt;p&gt;Users have been found to spend almost twice their time on apps on the iOS platform as compared to the Android apps.&lt;/p&gt;

&lt;p&gt;It is also intriguing that the iOS platform appeals to a target audience that put style, simplicity, and uniformity before anything else.&lt;/p&gt;

&lt;p&gt;The iOS operating system, therefore, is the best choice if you aim to flourish in the premium smartphone market without necessarily targeting mass adoption of the app.&lt;/p&gt;

&lt;p&gt;The Android operating system, on the other hand, is best suited where there’s need for a non-restrictive platform that offers more flexibility in publishing apps to the target audience.&lt;/p&gt;

&lt;h3&gt;
  
  
  2. Your Budget
&lt;/h3&gt;

&lt;p&gt;The resources available at your disposal towards the development of an app also determine the platform you choose for the application. &lt;/p&gt;

&lt;p&gt;Developing an Android app will normally require more time and resources compared to an iOS app. This, therefore, makes it more expensive in addition to the need for fragmentation.&lt;/p&gt;

&lt;p&gt;For Android app development, responsive designs have to be built to fit in different screen sizes and be available for various versions of the operating systems while accommodating the different technical capabilities.&lt;/p&gt;

&lt;p&gt;Another downside of the Android development platform is its incompatibility with some mobile devices as well as superior consumption of RAM. An Android app requires more lines of code compared to an iOS app with developers writing about 40% more for the Android.&lt;/p&gt;

&lt;p&gt;The Apple brand has a strong reputation for its intuitiveness and maturity when it comes to its apps and operating system. &lt;/p&gt;

&lt;p&gt;It boasts of its Xcode which offers excellent development tools for app builders that make the process of building and debugging smooth and proficient.&lt;/p&gt;

&lt;p&gt;Piracy of apps on iOS is also difficult thanks to the Xcode being a closed system. The same cannot be said of the Android platform.&lt;/p&gt;

&lt;p&gt;Your budget will also come into question when choosing the best operating system based on the app’s quality. Despite the Android Studio allowing for beta testing of the apps, its functionalities and features are still inferior.&lt;/p&gt;

&lt;p&gt;Android apps of low quality often translate to higher costs as a result of constant maintenance which can be quite bothersome, if you are on a low budget.&lt;/p&gt;

&lt;p&gt;Considering the long-term costs when launching a mobile app, the iOS is the best choice since the Apple Store requires a recurring $99 annual payment.&lt;/p&gt;

&lt;p&gt;Google play, on the other hand, charges a paltry one-off payment of $25 but the maintenance costs will definitely hit the roof. &lt;/p&gt;

&lt;p&gt;Therefore, knowing the difference between iOS and Android development costs can assist you to make a sound decision. &lt;/p&gt;

&lt;h3&gt;
  
  
  3. The Potential Benefits
&lt;/h3&gt;

&lt;p&gt;You will also have to consider the potential benefits that will accrue once you launch your application. &lt;/p&gt;

&lt;p&gt;The likely gains you will reap from advertisements and the driving of in-app purchases should influence your choice of a development platform. &lt;/p&gt;

&lt;p&gt;What is more important to you: is it app engagement or app popularity? Is evaluating Android vs. iOS difficulty essential?&lt;/p&gt;

&lt;p&gt;If you are looking forward to driving in-app purchases, then iOS is the best choice given that most of its users are on a higher income level and will likely use twice as much time on apps compared to Android users. &lt;/p&gt;

&lt;p&gt;Therefore, if you are chasing the money and would like to sell your apps and drive other in-app purchases, Apple users are your best bet.&lt;/p&gt;

&lt;p&gt;The Android operating system, on the other hand, is best for advertisement related benefits. Ad-supported content performs best on the Android platform which greatly drives mobile monetization. &lt;/p&gt;

&lt;p&gt;The operating system’s popularity with a wider base of users allows you to access a larger audience which greatly boosts your revenue streams through the in-app advertisements.&lt;/p&gt;

&lt;p&gt;It is important, therefore, that your choice of a development platform is in line with your app development goals for you to reap maximum benefits.&lt;/p&gt;

&lt;h3&gt;
  
  
  Conclusion
&lt;/h3&gt;

&lt;p&gt;The battle for supremacy between iOS vs. Android development for building apps is not likely to end any time soon. &lt;/p&gt;

&lt;p&gt;In fact, you should expect it to escalate even further as the two operating system bigwigs try to outdo each other as they improve on their features and functionalities.&lt;/p&gt;

&lt;p&gt;This will definitely work to the app developers’ advantage as the development platforms improve to unprecedented levels.&lt;/p&gt;

&lt;p&gt;Ultimately, you should go for the platform that best meets your needs and helps you to achieve your app development goals.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.liveedu.tv/projects/premium/programming/swift/"&gt;Click here&lt;/a&gt; to learn about iOS app development.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.liveedu.tv/projects/premium/programming/android/"&gt;Click here&lt;/a&gt; to learn about Android app development.&lt;/p&gt;

</description>
      <category>ios</category>
      <category>android</category>
      <category>appdevelopment</category>
    </item>
    <item>
      <title>How to Create Your Own Cryptocurrency Blockchain in Node.js</title>
      <dc:creator>Dr. Michael Garbade</dc:creator>
      <pubDate>Tue, 07 Aug 2018 22:09:44 +0000</pubDate>
      <link>https://forem.com/educationecosystem/how-to-create-your-own-cryptocurrency-blockchain-in-nodejs-274c</link>
      <guid>https://forem.com/educationecosystem/how-to-create-your-own-cryptocurrency-blockchain-in-nodejs-274c</guid>
      <description>&lt;p&gt;(This article was originally published on my blog &lt;a href="http://blog.liveedu.tv/how-to-create-your-own-cryptocurrency-blockchain-in-node-js/" rel="noopener noreferrer"&gt;here&lt;/a&gt; ).&lt;/p&gt;

&lt;p&gt;The recent explosion of cryptocurrencies and their underlying blockchain technology has taken the world by storm.&lt;/p&gt;

&lt;p&gt;As much as blockchain is a big buzz word these days, few people properly understand how the technology works to power the incredible growth of cryptos like Bitcoin and Ethereum.&lt;/p&gt;

&lt;p&gt;Elliot Minns, who has more than six years of software development experience and currently teaches people skills on how to create cryptocurrencies, says that “making your hands dirty by learning how to create blockchain will assist you appreciate the technology and how it works.” &lt;/p&gt;

&lt;p&gt;You can check one of his practical-based projects &lt;a href="https://www.liveedu.tv/elliottminns/l3Xa0-how-to-create-your-own-cryptocurrency-in-c/" rel="noopener noreferrer"&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;In this article, we are going to explain how you can create your own simple blockchain in Node.js (and release it to the world, hopefully!). &lt;/p&gt;

&lt;p&gt;We’ll call it &lt;strong&gt;liveEduCoin&lt;/strong&gt;. &lt;/p&gt;

&lt;h2&gt;
  
  
  Blockchains
&lt;/h2&gt;

&lt;p&gt;A blockchain is a constantly increasing list of records, referred to as blocks, which are securely connected to each other using cryptography. &lt;/p&gt;

&lt;p&gt;The blocks are linked such that if any block within the blockchain is tampered with, the rest of the chain becomes invalid.&lt;/p&gt;

&lt;p&gt;This immutability property is central to the growth of cryptocurrencies because it makes it difficult for people to alter their transactions after completing them. &lt;/p&gt;

&lt;h2&gt;
  
  
  Creating a block
&lt;/h2&gt;

&lt;p&gt;As mentioned earlier, a blockchain comprises of several blocks that are connected to one another. Cryptographic hashes are used to maintain the integrity of the blockchain. &lt;/p&gt;

&lt;p&gt;Every block has a hash that is calculated based on its data. It also has the hash of the preceding block. If the hash of any block is changed, it would invalidate the rest of the blockchain.&lt;/p&gt;

&lt;p&gt;Here is how a &lt;strong&gt;Block&lt;/strong&gt; class would look like in Node.js:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;SHA256&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;require&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;crypto-js/sha256&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Block&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nf"&gt;constructor&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;index&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;timestamp&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;data&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;previousHash&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;''&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;index&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;index&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;previousHash&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;previousHash&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;timestamp&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;timestamp&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;data&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;data&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;hash&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;computeHash&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
        &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;nonce&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="nf"&gt;computeHash&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nc"&gt;SHA256&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;index&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;previousHash&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;timestamp&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nx"&gt;JSON&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;stringify&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;data&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;nonce&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;toString&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;As you can see above, the &lt;strong&gt;constructor&lt;/strong&gt; function, which instantiates the class, takes the following parameters:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;index—it tracks the position of a block in a blockchain. &lt;/li&gt;
&lt;li&gt;timestamp—it places a timestamp of every transaction completed.&lt;/li&gt;
&lt;li&gt;data—it provides information about the transactions completed, such as the quantity bought.&lt;/li&gt;
&lt;li&gt;previousHash—it references the hash of the preceding block in the blockchain.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;We used the computeHash function to generate the cryptographic hash of every block according to the above values. To do this, we imported the &lt;a href="https://www.npmjs.com/package/crypto-js" rel="noopener noreferrer"&gt;crypto-js&lt;/a&gt; library and utilized its SHA256 hash function. &lt;/p&gt;

&lt;p&gt;The SHA256 is a strong, irreversible hash function that is used for ensuring the security of most cryptocurrencies.&lt;/p&gt;

&lt;p&gt;To set up the crypto-js library, navigate to the terminal, and on the same folder as your project folder, install it using &lt;strong&gt;npm&lt;/strong&gt;. &lt;/p&gt;

&lt;p&gt;Here is the code you can use:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;
&lt;span class="c1"&gt;//remember to run npm init first&lt;/span&gt;
&lt;span class="nx"&gt;npm&lt;/span&gt; &lt;span class="nx"&gt;install&lt;/span&gt; &lt;span class="o"&gt;--&lt;/span&gt;&lt;span class="nx"&gt;save&lt;/span&gt; &lt;span class="nx"&gt;crypto&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nx"&gt;js&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Creating the blockchain
&lt;/h2&gt;

&lt;p&gt;Block-chain is based on a concept that the blocks are “chained” to one another. &lt;/p&gt;

&lt;p&gt;Therefore, we’ll begin chaining the blocks to each other in a &lt;strong&gt;Blockchain&lt;/strong&gt; class. &lt;br&gt;
Here is the code:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Blockchain&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nf"&gt;constructor&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;chain&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;buildGenesisBlock&lt;/span&gt;&lt;span class="p"&gt;()];&lt;/span&gt;
        &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;complexity&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="nf"&gt;buildGenesisBlock&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;Block&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;17/07/2018&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;genesis block&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;0&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="nf"&gt;obtainLatestBlock&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;chain&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;chain&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;length&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;];&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="nf"&gt;addBlock&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;newBlock&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="nx"&gt;newBlock&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;previousHash&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;obtainLatestBlock&lt;/span&gt;&lt;span class="p"&gt;().&lt;/span&gt;&lt;span class="nx"&gt;hash&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="nx"&gt;newBlock&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;mineBlock&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;complexity&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
        &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;chain&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;push&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;newBlock&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;As you can see on the above code, the class is composed of the following helper functions:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;a). Constructor function&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The blockchain is initialized by passing &lt;strong&gt;buildGenesisBlock&lt;/strong&gt;. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;b). Building the genesis block&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;In a blockchain, the genesis block is what signifies the start of the blockchain. This initial block doesn’t have any predecessors and the subsequent blocks are built on it. &lt;/p&gt;

&lt;p&gt;We’ll use the &lt;strong&gt;buildGenesisBlock()&lt;/strong&gt; function to create it. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;c). Getting the latest block&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;To get the latest block in the blockchain, we’ll use the &lt;strong&gt;obtainLatestBlock()&lt;/strong&gt; function. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;d). Adding new block&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;To add a new block to the blockchain Node.js example, we’ll use the &lt;strong&gt;addBlock()&lt;/strong&gt; function. To achieve this, we’ll add the hash of the previous block to the new block—to maintain the blockchain’s integrity. &lt;/p&gt;

&lt;p&gt;Since we altered the details of the new block, it will be essential to compute its hash once more. After it is completed, we’ll push the block into the chain array. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;e). Confirming the validity of the blockchain&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The &lt;strong&gt;confirmValidity()&lt;/strong&gt; function is pivotal in assessing the integrity of the blockchain and ensuring that flaws are absent. This function employs a series of &lt;strong&gt;if&lt;/strong&gt; statements to confirm whether the hash of every block is unaltered.&lt;/p&gt;

&lt;p&gt;Additionally, it also checks if the hash values of every two successive blocks are pointing to each other. If everything is valid, it returns true; otherwise, it returns false. &lt;/p&gt;

&lt;p&gt;Here is the code:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nf"&gt;confirmValidity&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;for &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;i&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nx"&gt;i&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;chain&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;length&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nx"&gt;i&lt;/span&gt;&lt;span class="o"&gt;++&lt;/span&gt;&lt;span class="p"&gt;){&lt;/span&gt;
            &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;currentBlock&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;chain&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;i&lt;/span&gt;&lt;span class="p"&gt;];&lt;/span&gt;
            &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;previousBlock&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;chain&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;i&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;];&lt;/span&gt;
            &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;currentBlock&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;hash&lt;/span&gt; &lt;span class="o"&gt;!==&lt;/span&gt; &lt;span class="nx"&gt;currentBlock&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;computeHash&lt;/span&gt;&lt;span class="p"&gt;())&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
                &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
            &lt;span class="p"&gt;}&lt;/span&gt;
            &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;currentBlock&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;previousHash&lt;/span&gt; &lt;span class="o"&gt;!==&lt;/span&gt; &lt;span class="nx"&gt;previousBlock&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;hash&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
                &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
            &lt;span class="p"&gt;}&lt;/span&gt;
        &lt;span class="p"&gt;}&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Testing the blockchain
&lt;/h2&gt;

&lt;p&gt;This is the most exciting section!&lt;/p&gt;

&lt;p&gt;Here is the code:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;liveEduCoin&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;Blockchain&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;&amp;lt;&amp;lt;Lets mine block 1&amp;gt;&amp;gt;&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="nx"&gt;liveEduCoin&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;addBlock&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;Block&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;27/07/2018&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;quantity&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;10&lt;/span&gt; &lt;span class="p"&gt;}));&lt;/span&gt;
&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;&amp;lt;&amp;lt;Lets mine block 2&amp;gt;&amp;gt;&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="nx"&gt;liveEduCoin&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;addBlock&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;Block&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;27/07/2018&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;quantity&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;20&lt;/span&gt; &lt;span class="p"&gt;}));&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We’ll create a new instance of the Blockchain class and name it &lt;strong&gt;liveEduCoin&lt;/strong&gt;. &lt;/p&gt;

&lt;p&gt;Thereafter, we’ll add some arbitrary blocks into the blockchain. You can add any kind of data into the blocks. &lt;/p&gt;

&lt;p&gt;In this simple blockchain Node.js tutorial, we decided to add an object with the &lt;strong&gt;quantity&lt;/strong&gt; property.&lt;/p&gt;

&lt;p&gt;Here is the entire code for our blockchain project:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;SHA256&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;require&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;crypto-js/sha256&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Block&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nf"&gt;constructor&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;index&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;timestamp&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;data&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;previousHash&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;''&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;index&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;index&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;previousHash&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;previousHash&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;timestamp&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;timestamp&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;data&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;data&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;hash&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;computeHash&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
        &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;nonce&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="nf"&gt;computeHash&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nc"&gt;SHA256&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;index&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;previousHash&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;timestamp&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nx"&gt;JSON&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;stringify&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;data&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;nonce&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;toString&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="nf"&gt;mineBlock&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;complexity&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;while &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;hash&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;substring&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;complexity&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;!==&lt;/span&gt; &lt;span class="nc"&gt;Array&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;complexity&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;join&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;0&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;nonce&lt;/span&gt;&lt;span class="o"&gt;++&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
            &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;hash&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;computeHash&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
        &lt;span class="p"&gt;}&lt;/span&gt;
        &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Mining is taking place: &lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;hash&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Blockchain&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nf"&gt;constructor&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;chain&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;buildGenesisBlock&lt;/span&gt;&lt;span class="p"&gt;()];&lt;/span&gt;
        &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;complexity&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="nf"&gt;buildGenesisBlock&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;Block&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;17/07/2018&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;genesis block&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;0&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="nf"&gt;obtainLatestBlock&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;chain&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;chain&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;length&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;];&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="nf"&gt;addBlock&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;newBlock&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="nx"&gt;newBlock&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;previousHash&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;obtainLatestBlock&lt;/span&gt;&lt;span class="p"&gt;().&lt;/span&gt;&lt;span class="nx"&gt;hash&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="nx"&gt;newBlock&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;mineBlock&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;complexity&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
        &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;chain&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;push&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;newBlock&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="nf"&gt;confirmValidity&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;for &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;i&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nx"&gt;i&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;chain&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;length&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nx"&gt;i&lt;/span&gt;&lt;span class="o"&gt;++&lt;/span&gt;&lt;span class="p"&gt;){&lt;/span&gt;
            &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;currentBlock&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;chain&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;i&lt;/span&gt;&lt;span class="p"&gt;];&lt;/span&gt;
            &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;previousBlock&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;chain&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;i&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;];&lt;/span&gt;

            &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;currentBlock&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;hash&lt;/span&gt; &lt;span class="o"&gt;!==&lt;/span&gt; &lt;span class="nx"&gt;currentBlock&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;computeHash&lt;/span&gt;&lt;span class="p"&gt;())&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
                &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
            &lt;span class="p"&gt;}&lt;/span&gt;

            &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;currentBlock&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;previousHash&lt;/span&gt; &lt;span class="o"&gt;!==&lt;/span&gt; &lt;span class="nx"&gt;previousBlock&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;hash&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
                &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
            &lt;span class="p"&gt;}&lt;/span&gt;
        &lt;span class="p"&gt;}&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;liveEduCoin&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;Blockchain&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;&amp;lt;&amp;lt;Lets mine block 1&amp;gt;&amp;gt;&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="nx"&gt;liveEduCoin&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;addBlock&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;Block&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;27/07/2018&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;quantity&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;10&lt;/span&gt; &lt;span class="p"&gt;}));&lt;/span&gt;
&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;&amp;lt;&amp;lt;Lets mine block 2&amp;gt;&amp;gt;&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="nx"&gt;liveEduCoin&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;addBlock&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;Block&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;27/07/2018&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;quantity&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;20&lt;/span&gt; &lt;span class="p"&gt;}));&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If we save the code on a blockchain.js file and run it on the terminal, here is the output:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fiq4w64n1yhza0pgglrjr.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fiq4w64n1yhza0pgglrjr.jpg" alt="cryptocurrency blockchain in Node.js"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;It works!&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;The above cryptocurrency blockchain in Node.js is far from complete. In fact, if you go ahead and release it to the world, you can end up to be the only one using it!&lt;/p&gt;

&lt;p&gt;For example, it lacks important tenets of a successful cryptocurrency such as proof-of-work and a peer-to-peer network.&lt;/p&gt;

&lt;p&gt;Nonetheless, the blockchain node.js demo shows how a blockchain works. Contrary to what many people think, this simple project illustrates that the concepts of blockchain are simple and easy to implement.&lt;/p&gt;

&lt;p&gt;Of course, if you are looking for a more advanced project to entirely immerse yourself in the world of cryptocurrencies, you can &lt;a href="https://www.liveedu.tv/projects/premium/cryptocurrency/?q=crypto" rel="noopener noreferrer"&gt;click here&lt;/a&gt; to grab a tutorial from the LiveEdu website. &lt;/p&gt;

</description>
      <category>cryptocurrency</category>
      <category>blockchain</category>
      <category>node</category>
      <category>liveedu</category>
    </item>
    <item>
      <title>2018 FIFA World Cup: Three Key Lessons for Web and Mobile Developers</title>
      <dc:creator>Dr. Michael Garbade</dc:creator>
      <pubDate>Wed, 01 Aug 2018 22:36:52 +0000</pubDate>
      <link>https://forem.com/educationecosystem/2018-fifa-world-cup-three-key-lessons-for-web-and-mobile-developers-59mn</link>
      <guid>https://forem.com/educationecosystem/2018-fifa-world-cup-three-key-lessons-for-web-and-mobile-developers-59mn</guid>
      <description>&lt;p&gt;(This article was originally published on my blog &lt;a href="http://blog.liveedu.tv/2018-fifa-world-cup-three-key-lessons-for-web-and-mobile-developers/"&gt;here&lt;/a&gt; ).&lt;/p&gt;

&lt;p&gt;Besides the thrill and entertainment that the 2018 FIFA World Cup brought, it was full of critical lessons that web and mobile developers can use to take their careers to the next level.&lt;/p&gt;

&lt;p&gt;From big teams falling to the underdogs to technology making critical match-changing decisions to surprises filling the stadiums, the happenings during the World Cup carries with it lessons—beyond the 90+ minutes that each match was played.&lt;/p&gt;

&lt;p&gt;For example, if you want to create an online voting web application like Ricardo does it &lt;a href="https://www.liveedu.tv/sheepcow/RxLWp-how-to-create-an-online-voting-webapp-java/"&gt;here&lt;/a&gt;, or any other type of application, the soccer event could inculcate important lessons to help you sew things together well. &lt;/p&gt;

&lt;p&gt;Here are three key 2018 World Cup lessons that programmers can take home from the monumental sporting event. &lt;/p&gt;

&lt;h2&gt;
  
  
  1. Overcome your odds—no matter what it takes
&lt;/h2&gt;

&lt;p&gt;Although Croatia lost to France in the final match by 4-2, the Croatian team will be remembered as the greatest underdog performance in the tournament’s history. &lt;/p&gt;

&lt;p&gt;Croatia, with a population of four million people—one-13th the size of England's—surmounted economic and demographic odds to brush shoulders with the giants and reach the event’s pinnacle.&lt;/p&gt;

&lt;p&gt;Furthermore, how the little country with big dreams showed an indomitable spirit throughout the matches is encouraging. In most of the matches, the Croatian team had to claw back from behind—after conceding some goals—which affirms its strong endurance and never-say-die attitude.&lt;/p&gt;

&lt;p&gt;Actually, the team won three knock-out matches during overtime, demonstrating their mental strength under massive pressure.&lt;/p&gt;

&lt;p&gt;As a web or mobile developer, how many times do you throw tantrums when your code doesn’t compile? When things seem not to be working, do you give up coding the application altogether or you reevaluate your mistakes and seek for assistance?&lt;/p&gt;

&lt;p&gt;As demonstrated by the endurance of the Croatian team, you need to safeguard your weaknesses through overplaying your strengths—without lamenting at the odds that are against you.&lt;/p&gt;

&lt;h2&gt;
  
  
  2. Embrace teamwork
&lt;/h2&gt;

&lt;p&gt;Emerging winners in a football match requires experts in various domains—goalkeepers, defenders, midfielders, strikers, and coaches—to work together to achieve the victory. Every player has a role that he needs to deliver, while collaborating with the others in the field. &lt;/p&gt;

&lt;p&gt;In the 2018 World Cup results, the players that embraced teamwork brought glory to their countries. For example, France took home the trophy because of their wonderful display of teamwork.&lt;/p&gt;

&lt;p&gt;Almost half of the French team consisted of African-immigrant players. The former U.S. President &lt;a href="https://www.cbsnews.com/news/president-obama-full-speech-south-africa/"&gt;Barack Obama&lt;/a&gt;, during a recent lecture to celebrate 100 years since the birth of President Nelson Mandela said that “embracing diversity delivers practical benefits since it ensures that a society can draw upon the energy and skills of all people. And if you doubt that, just ask the French football team that just won the World Cup.”&lt;/p&gt;

&lt;p&gt;As a developer, you need to learn how to work with others, regardless of their backgrounds and nationalities. If members of a team complement one another’s development skills and collectively join hands in completing tasks, they become more productive as a unit than when working at individual levels. &lt;/p&gt;

&lt;p&gt;If you are a coding superstar and you cannot work together as a unit with other programmers in your team, the chances of success will be dwindled. &lt;/p&gt;

&lt;p&gt;For example, although Portugal and Argentina had the most talented and awe-inspiring stars in their squads—in Christiano Ronaldo and Lionel Messi respectively—they were unable to utilize teamwork to reach the tournament’s pinnacle.&lt;/p&gt;

&lt;h2&gt;
  
  
  3. Embrace new technology
&lt;/h2&gt;

&lt;p&gt;For the first time in the history of football, new technologies were used extensively during the FIFA 2018 World Cup to assist the match officials in making game-changing decisions. &lt;/p&gt;

&lt;p&gt;For example, a notable technology that has ignited a lot of debate is the Video Assistant Referee (VAR). The video technology was introduced to assist referees review footages of the game before making critical decisions, such as during the final match when the referee used the VAR footage to award France a 38th-minute penalty.&lt;/p&gt;

&lt;p&gt;The fact that FIFA, the organization that governs football in the world, adopted new technologies to improve the quality of the tournament shows its commitment to ride with the changing times; the world is quickly adopting new technologies to improve processes and enhance efficiency of outputs. &lt;/p&gt;

&lt;p&gt;As a web developer or mobile developer, you should also continuously adopt new technologies or your applications may not meet the current demands of the modern audience. &lt;/p&gt;

&lt;p&gt;For example, why should you rely on legacy code that will give you maintenance headaches while a new framework has been released that can improve the efficiency of your operations?&lt;/p&gt;

&lt;h2&gt;
  
  
  Wrapping up
&lt;/h2&gt;

&lt;p&gt;The 2018 FIFA World Cup has been concluded but the lessons that it brought to the fore are long lasting—especially for developers who often struggle with issues impeding their growth. &lt;/p&gt;

&lt;p&gt;What other lesson(s) did you learn from the concluded popular football tournament? &lt;/p&gt;

&lt;p&gt;Which one(s) will you use to progress your &lt;a href="https://www.liveedu.tv/projects/premium/programming/"&gt;programming&lt;/a&gt; career?&lt;/p&gt;

&lt;p&gt;Please share with us in the comment section below.&lt;/p&gt;

</description>
      <category>2018fifaworldcup</category>
      <category>lessons</category>
      <category>webmobiledevelopers</category>
    </item>
    <item>
      <title>A Simple Machine Learning Algorithm to Differentiate Between an Apple and an Orange</title>
      <dc:creator>Dr. Michael Garbade</dc:creator>
      <pubDate>Fri, 20 Jul 2018 21:45:58 +0000</pubDate>
      <link>https://forem.com/educationecosystem/a-simple-machine-learning-algorithm-to-differentiate-between-an-apple-and-an-orange-2bpk</link>
      <guid>https://forem.com/educationecosystem/a-simple-machine-learning-algorithm-to-differentiate-between-an-apple-and-an-orange-2bpk</guid>
      <description>&lt;p&gt;(This article was originally published on the &lt;a href="http://blog.liveedu.tv/a-simple-machine-learning-algorithm-to-differentiate-between-an-apple-and-an-orange/"&gt;LiveEdu blog&lt;/a&gt;).&lt;/p&gt;

&lt;p&gt;Machine learning (abbreviated as ML) is a field of computer science that endows applications with the capability to automatically learn from examples and improve from that experience without relying on hard-coded rules. &lt;/p&gt;

&lt;p&gt;With machine learning, it is possible for computers to identify hidden insights and make accurate predictions based on the examples of data provided—with minimal human intervention.&lt;/p&gt;

&lt;p&gt;For example, AndreyBu, who has over five years of ML experience, has created a model that can predict stock market data. You can watch and learn from his project &lt;a href="https://www.liveedu.tv/andreybu/REaxr-machine-learning-model-python-sklearn-kera/"&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;In this article, we are going to illustrate how to create a simple machine learning algorithm that can differentiate between an apple and orange.&lt;/p&gt;

&lt;p&gt;Without machine learning, finding a solution to such a problem could require writing several lines of code, which may not give the desired results. ML simplifies that process.&lt;/p&gt;

&lt;p&gt;Simply, we will create a machine learning algorithm that can learn the differences between the two fruits and make predictions accordingly, after being given some examples. &lt;/p&gt;

&lt;h2&gt;
  
  
  Let’s get started
&lt;/h2&gt;

&lt;p&gt;We are going to use the &lt;a href="https://anaconda.org/anaconda/python"&gt;Anaconda&lt;/a&gt; open source Python distribution. It comes with Scikit-learn, which is the machine learning library we’ll use to implement our algorithm.&lt;/p&gt;

&lt;p&gt;In this example, we are going to use a supervised machine learning algorithm, which utilizes a known dataset (referred to as the training dataset) to predict future events.&lt;/p&gt;

&lt;p&gt;The training dataset, which consists of input data and output values, learns from the examples provided and makes use of the experience to distinguish between the two fruits.&lt;/p&gt;

&lt;p&gt;Here is a general flow of the supervised learning recipe:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Gather training data&lt;/li&gt;
&lt;li&gt;Train the classifier&lt;/li&gt;
&lt;li&gt;Make predictions&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Let’s talk about each of the steps.&lt;/p&gt;

&lt;h2&gt;
  
  
  1. Gathering training data
&lt;/h2&gt;

&lt;p&gt;The training data are the examples of apples and oranges that we’ll classify according to their differences. &lt;/p&gt;

&lt;p&gt;Here is a table that uses the features of the two fruits to differentiate them:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--l9ytdXS8--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/ofiqqm5x6v0tz7cz66gs.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--l9ytdXS8--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/ofiqqm5x6v0tz7cz66gs.png" alt="two fruits features"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;As you can see above, the fruits are differentiated according to their weight and texture. &lt;/p&gt;

&lt;p&gt;The last column in every row is what is called &lt;em&gt;label&lt;/em&gt; in machine learning. In this case, the label can either be an orange or an apple. &lt;/p&gt;

&lt;p&gt;Every row in the table is called a &lt;em&gt;data point&lt;/em&gt;. The whole table is called the &lt;em&gt;training data&lt;/em&gt;. &lt;/p&gt;

&lt;p&gt;It’s important to note that the accuracy of the outcome will depend on the number of examples provided in the training data. &lt;/p&gt;

&lt;p&gt;Now, let’s use some Python code to show what is happening in the table.&lt;/p&gt;

&lt;p&gt;We will use two variables: &lt;em&gt;features&lt;/em&gt; (data in the first two columns) and &lt;em&gt;labels&lt;/em&gt; (data in the last column). &lt;/p&gt;

&lt;p&gt;In other words, features are the input data and labels are the output values.&lt;/p&gt;

&lt;p&gt;Here is the code:&lt;/p&gt;



&lt;div class="highlight"&gt;&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;features&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[[&lt;/span&gt;&lt;span class="mi"&gt;155&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"rough"&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;180&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"rough"&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;135&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"smooth"&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;110&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"smooth"&lt;/span&gt;&lt;span class="p"&gt;]]&lt;/span&gt; 
&lt;span class="n"&gt;labels&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s"&gt;"orange"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"orange"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"apple"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"apple"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Next, because Scikit-learn requires numerical features, let’s convert the strings into integers by defining rough as &lt;em&gt;0&lt;/em&gt; and smooth as &lt;em&gt;1&lt;/em&gt;. &lt;/p&gt;

&lt;p&gt;Let’s do the same for the oranges and apples by giving them integer values of &lt;em&gt;1&lt;/em&gt; and &lt;em&gt;0&lt;/em&gt; respectively. &lt;/p&gt;

&lt;p&gt;Here is our new code:&lt;/p&gt;



&lt;div class="highlight"&gt;&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;features&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[[&lt;/span&gt;&lt;span class="mi"&gt;155&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;180&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;135&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;110&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;]]&lt;/span&gt;  
&lt;span class="n"&gt;labels&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h2&gt;
  
  
  2. Training the classifier
&lt;/h2&gt;

&lt;p&gt;In ML, classification is a supervised learning technique whereby the algorithm learns from the examples data and then utilizes the experience to categorize the new observation. &lt;/p&gt;

&lt;p&gt;Now, we’ll use the examples data to train our classifier to make new observations and categorize them. There are several types of classifiers you can use in your machine learning problems. &lt;/p&gt;

&lt;p&gt;In this case, to keep things simple, we are going to use a decision tree, which can use decision rules deduced from the data features to learn and make appropriate predictions. &lt;/p&gt;

&lt;p&gt;Here is a code that imports the decision tree classifier and adds it to our project:&lt;/p&gt;



&lt;div class="highlight"&gt;&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;classifier&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;tree&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;DecisionTreeClassifier&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; 
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;After adding the classifier to our project, we’ll need to train it using a learning algorithm; otherwise, it may not differentiate between an apple and an orange. &lt;/p&gt;

&lt;p&gt;The learning algorithm identifies patterns in the training data and makes suitable conclusions.&lt;/p&gt;

&lt;p&gt;For example, it may recognize that apples tend to be smoother in texture; therefore, it will develop a rule that tends to identify any smooth fruit as an apple. &lt;/p&gt;

&lt;p&gt;In Scikit-learn, the training algorithm is referred to as Fit (which can loosely be interpreted as “find patterns in data.”).&lt;/p&gt;

&lt;p&gt;Here is a code that adds it to our project:&lt;/p&gt;



&lt;div class="highlight"&gt;&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;classifier&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;classifier&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;fit&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;features&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;labels&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;  
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h2&gt;
  
  
  3. Making predictions
&lt;/h2&gt;

&lt;p&gt;The last step after subjecting the classifier to some training is to test it and see if it can classify a new fruit. We’ll use the &lt;em&gt;predict&lt;/em&gt; function to make the predictions. &lt;/p&gt;

&lt;p&gt;Let’s say that the new fruit is smooth and weighs 120 grams. Remember that we represented smooth as &lt;em&gt;1&lt;/em&gt;. &lt;/p&gt;

&lt;p&gt;And, because the weight is not very high, it is likely to be an apple &lt;em&gt;(0)&lt;/em&gt;. &lt;/p&gt;

&lt;p&gt;Furthermore, smoothness is a feature of apples.&lt;/p&gt;

&lt;p&gt;Let’s see if our ML algorithm can make such a prediction:&lt;/p&gt;



&lt;div class="highlight"&gt;&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;print&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;classifier&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;predict&lt;/span&gt;&lt;span class="p"&gt;([[&lt;/span&gt;&lt;span class="mi"&gt;120&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;]]))&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;It works!&lt;/p&gt;

&lt;p&gt;The output is what we expected: 0 (apple).&lt;/p&gt;

&lt;h2&gt;
  
  
  Wrapping up
&lt;/h2&gt;

&lt;p&gt;Here is the entire code for the project:&lt;/p&gt;



&lt;div class="highlight"&gt;&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="nn"&gt;sklearn&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;tree&lt;/span&gt;
 &lt;span class="c1"&gt;# Gathering training data
# features = [[155, "rough"], [180, "rough"], [135, "smooth"], [110, "smooth"]]  # Input to classifier
&lt;/span&gt;&lt;span class="n"&gt;features&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[[&lt;/span&gt;&lt;span class="mi"&gt;155&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;180&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;135&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;110&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;]]&lt;/span&gt;  &lt;span class="c1"&gt;# scikit-learn requires real-valued features
# labels = ["orange", "orange", "apple", "apple"]  # output values
&lt;/span&gt;&lt;span class="n"&gt;labels&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
 &lt;span class="c1"&gt;# Training classifier
&lt;/span&gt;&lt;span class="n"&gt;classifier&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;tree&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;DecisionTreeClassifier&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;  &lt;span class="c1"&gt;# using decision tree classifier
&lt;/span&gt;&lt;span class="n"&gt;classifier&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;classifier&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;fit&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;features&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;labels&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;  &lt;span class="c1"&gt;# Find patterns in data
&lt;/span&gt; &lt;span class="c1"&gt;# Making predictions
&lt;/span&gt;&lt;span class="k"&gt;print&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;classifier&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;predict&lt;/span&gt;&lt;span class="p"&gt;([[&lt;/span&gt;&lt;span class="mi"&gt;120&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;]]))&lt;/span&gt;
&lt;span class="c1"&gt;# Output is 0 for apple
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Programming with machine learning is not difficult. To master how to use it in your applications, you need to understand a few important concepts. &lt;/p&gt;

&lt;p&gt;Therefore, to increase your skills, you can use practical projects from &lt;a href="https://www.liveedu.tv/projects/premium/artificial-intelligence/"&gt;LiveEdu&lt;/a&gt; to learn how experts build real world-changing machine learning applications.&lt;/p&gt;

&lt;p&gt;Happy learning machine learning!&lt;/p&gt;

</description>
      <category>machinelearning</category>
      <category>trainingdata</category>
      <category>classifier</category>
      <category>python</category>
    </item>
    <item>
      <title>Results of a Study to Understand JavaScript Bugs (and How to Avoid Them)</title>
      <dc:creator>Dr. Michael Garbade</dc:creator>
      <pubDate>Fri, 15 Jun 2018 19:44:36 +0000</pubDate>
      <link>https://forem.com/educationecosystem/results-of-a-study-to-understand-javascript-bugs-and-how-to-avoid-them-2e64</link>
      <guid>https://forem.com/educationecosystem/results-of-a-study-to-understand-javascript-bugs-and-how-to-avoid-them-2e64</guid>
      <description>&lt;p&gt;JavaScript is a popular programming language that is extensively used in web applications to enhance user-interactivity on the client side. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.liveedu.tv/benhartouz/lzNVQ-front-end-development/"&gt;Benhartouz&lt;/a&gt;, who is currently using JavaScript to teach people how to build a website for searching jobs, says that "unfortunately, the ubiquitous language is prone to bugs and errors, which make most developers frown and freak." You can visit the link to learn more about his project.&lt;/p&gt;

&lt;p&gt;Researchers from the University of British Columbia (UBC) recently carried out a &lt;a href="http://salt.ece.ubc.ca/publications/docs/frolin-tse16.pdf"&gt;study&lt;/a&gt; to understand the causes and consequences of client-side JavaScript faults and errors.&lt;/p&gt;

&lt;p&gt;The researchers investigated 502 bug reports from 19 bug repositories and discovered some common patterns that make JavaScript-powered applications to behave abnormally. &lt;/p&gt;

&lt;p&gt;Here is a table summarizing the findings of the study:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--k-etZwfX--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/umlwyav1c7960l0dpq48.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--k-etZwfX--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/umlwyav1c7960l0dpq48.png" alt="javascript bug study results"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In this article, I’m going to illustrate the key findings of the study and how you can make your JavaScript programs less prone to errors and performance failures.&lt;/p&gt;

&lt;h2&gt;
  
  
  1. DOM-related errors
&lt;/h2&gt;

&lt;p&gt;Surprisingly, according to the JavaScript bug report study, DOM-related faults accounted for most of the errors, at 68%. &lt;/p&gt;

&lt;p&gt;The Document Object Model, usually referred to as the DOM, is a dynamic tree-like structure that consists of the components in the application and how they interact with each other. &lt;/p&gt;

&lt;p&gt;With DOM API calls, you can utilize JavaScript to manipulate the constituents of the DOM, making the web page to be interactive without necessitating a page reload.&lt;/p&gt;

&lt;p&gt;As much as the features of the DOM allow developers to add interactivity to the applications, they are also one of the main avenues for introducing flaws in JavaScript applications.&lt;/p&gt;

&lt;p&gt;For example, a common mistake most developers make is to reference a DOM element before it is loaded on a web page. &lt;/p&gt;

&lt;p&gt;Here is the code:&lt;/p&gt;



&lt;div class="highlight"&gt;&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="o"&gt;&amp;lt;!&lt;/span&gt;&lt;span class="nx"&gt;DOCTYPE&lt;/span&gt; &lt;span class="nx"&gt;html&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;html&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;body&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
     &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;script&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;

&lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;getElementById&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;javascript&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nx"&gt;innerHTML&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;JavaScript is Fun!&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

  &lt;span class="c1"&gt;//it throws an output error&lt;/span&gt;
    &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/script&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;    &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;div&lt;/span&gt; &lt;span class="nx"&gt;id&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;javascript&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/div&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;    &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/body&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/html&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;If you run such a code, it will throw an error. JavaScript code usually loads and runs following the order it appears in a document; therefore, the browser will not know about the referenced element when the code is executed. &lt;/p&gt;

&lt;p&gt;There are a couple of ways of solving this problem:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Place the &lt;code&gt;&amp;lt;div id="javascript"&amp;gt;&amp;lt;/div&amp;gt;&lt;/code&gt; first before the script. &lt;/li&gt;
&lt;/ul&gt;



&lt;div class="highlight"&gt;&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="o"&gt;&amp;lt;!&lt;/span&gt;&lt;span class="nx"&gt;DOCTYPE&lt;/span&gt; &lt;span class="nx"&gt;html&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;html&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;body&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;

    &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;div&lt;/span&gt; &lt;span class="nx"&gt;id&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;javascript&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/div&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;
    &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;script&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;

&lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;getElementById&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;javascript&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nx"&gt;innerHTML&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;JavaScript is Fun!&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

  &lt;span class="c1"&gt;//it does not throw an output error&lt;/span&gt;

    &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/script&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;
&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/body&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/html&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Use the JavaScript &lt;code&gt;onload&lt;/code&gt; event attribute to run the code immediately after the page has been loaded.
&lt;/li&gt;
&lt;/ul&gt;



&lt;div class="highlight"&gt;&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="o"&gt;&amp;lt;!&lt;/span&gt;&lt;span class="nx"&gt;DOCTYPE&lt;/span&gt; &lt;span class="nx"&gt;html&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;html&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;body&lt;/span&gt; &lt;span class="nx"&gt;onload&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;bugJS()&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;

    &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;div&lt;/span&gt; &lt;span class="nx"&gt;id&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;javascript&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/div&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;
    &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;script&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;

       &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nx"&gt;bugJS&lt;/span&gt;&lt;span class="p"&gt;(){&lt;/span&gt;

     &lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;getElementById&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;javascript&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nx"&gt;innerHTML&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;JavaScript is Fun, yeah?&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

        &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/script&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;

&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/body&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/html&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h2&gt;
  
  
  2. Syntax-based errors
&lt;/h2&gt;

&lt;p&gt;The study found out that 12% of all JavaScript bugs were due to syntax errors in JavaScript programs. Syntax faults are due to grammatical errors that are not aligned to the standard syntax of the JavaScript programming language. &lt;/p&gt;

&lt;p&gt;Here are two common syntax-based errors:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Mismatched brackets &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This error often arises when you forget to match the brackets accordingly, especially when working on a complex application.&lt;/p&gt;

&lt;p&gt;Here is an example of a JavaScript object function without one corresponding closing bracket.&lt;/p&gt;



&lt;div class="highlight"&gt;&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;functionPerson&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="nx"&gt;street&lt;/span&gt;&lt;span class="p"&gt;){&lt;/span&gt;

&lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;name&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;street&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;street&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;info&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="kd"&gt;function&lt;/span&gt;&lt;span class="p"&gt;(){&lt;/span&gt;

&lt;span class="nx"&gt;returnthis&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;name&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt;&lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;street&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="c1"&gt;//closing bracket missing here&lt;/span&gt;

&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Missing a semicolon &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Although ending every statement with a semicolon is not necessary in JavaScript, and your code will execute without any problems, the problem usually comes when you have several lines of code, and some of them end up piling up on the same line. &lt;/p&gt;

&lt;p&gt;Therefore, it’s a good practice to always end your statements with a semicolon to avoid such bugs.&lt;/p&gt;

&lt;p&gt;To avoid making such grammatical errors in your code, you need to spend time increasing your skills in JavaScript programming. &lt;/p&gt;

&lt;p&gt;For example, &lt;a href="https://www.liveedu.tv/kauress/lj6eO-how-to-code-a-single-operation-calculator-in-javascript/"&gt;Kauress&lt;/a&gt;, who is from the U.S. and has over four years of experience in web programming, has completed a project on how to code a calculator using JavaScript. &lt;/p&gt;

&lt;p&gt;You can use his project to increase your skills in JavaScript programming and avoid making syntax errors. &lt;/p&gt;

&lt;p&gt;##3. Undefined and null errors&lt;/p&gt;

&lt;p&gt;The researchers at UBC discovered that misuse of &lt;code&gt;undefined&lt;/code&gt; and &lt;code&gt;null&lt;/code&gt; keywords lead to 9% of all JavaScript bugs. &lt;/p&gt;

&lt;p&gt;This result of the study implies that most JavaScript programmers do not understand how to use the two keywords correctly to avoid coding errors in JS web applications. &lt;/p&gt;

&lt;p&gt;The &lt;code&gt;null&lt;/code&gt; keyword is an assignment value, which is a representation of a non-existent value. It also behaves like an object. &lt;/p&gt;

&lt;p&gt;Here is an example:&lt;/p&gt;



&lt;div class="highlight"&gt;&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;bugJS&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

 &lt;span class="err"&gt;   &lt;/span&gt;&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;bugJS&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

 &lt;span class="err"&gt;     &lt;/span&gt; &lt;span class="err"&gt; &lt;/span&gt;&lt;span class="c1"&gt;// null is the output&lt;/span&gt;

  &lt;span class="err"&gt; &lt;/span&gt;&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;typeof&lt;/span&gt; &lt;span class="nx"&gt;bugJS&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

 &lt;span class="err"&gt;     &lt;/span&gt; &lt;span class="err"&gt; &lt;/span&gt;&lt;span class="c1"&gt;// object is the output&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Conversely, the &lt;code&gt;undefined&lt;/code&gt; keyword means that a declared variable or any other property does not have an assigned value. In fact, it is a type of itself. &lt;/p&gt;

&lt;p&gt;Here is an example:&lt;/p&gt;



&lt;div class="highlight"&gt;&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;bugJS&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

 &lt;span class="err"&gt;  &lt;/span&gt;&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;bugJS&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

 &lt;span class="err"&gt;     &lt;/span&gt; &lt;span class="err"&gt; &lt;/span&gt;&lt;span class="c1"&gt;// undefined is the output&lt;/span&gt;

  &lt;span class="err"&gt; &lt;/span&gt;&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;typeof&lt;/span&gt; &lt;span class="nx"&gt;bugJS&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

 &lt;span class="err"&gt;     &lt;/span&gt; &lt;span class="err"&gt; &lt;/span&gt;&lt;span class="c1"&gt;// undefined is the output&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Furthermore, when the &lt;code&gt;null&lt;/code&gt; and &lt;code&gt;undefined&lt;/code&gt; keywords are compared with one another using the equality and identity operator, it is only the former that considers them to be equal.&lt;/p&gt;



&lt;div class="highlight"&gt;&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="o"&gt;==&lt;/span&gt;&lt;span class="kc"&gt;undefined&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

 &lt;span class="err"&gt;      &lt;/span&gt;&lt;span class="c1"&gt;//true&lt;/span&gt;

 &lt;span class="err"&gt; &lt;/span&gt;&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="o"&gt;===&lt;/span&gt;&lt;span class="kc"&gt;undefined&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

 &lt;span class="err"&gt;      &lt;/span&gt;&lt;span class="c1"&gt;//false&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h2&gt;
  
  
  4. Improper usage of the return statement
&lt;/h2&gt;

&lt;p&gt;The &lt;code&gt;return&lt;/code&gt; statement is used to tell the interpreter that the running of a JavaScript function is completed, and the value needs to be returned. &lt;/p&gt;

&lt;p&gt;According to the results of the study, improper usage of the return statement accounts for 2% of all JavaScript bugs. &lt;/p&gt;

&lt;p&gt;For example, a common error most web programmers make is to break the &lt;code&gt;return&lt;/code&gt; statement.&lt;/p&gt;

&lt;p&gt;Here is a code example:&lt;/p&gt;



&lt;div class="highlight"&gt;&lt;pre class="highlight javascript"&gt;&lt;code&gt;
&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nx"&gt;bugJS&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;z&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;

 &lt;span class="err"&gt;   &lt;/span&gt;&lt;span class="kd"&gt;var&lt;/span&gt;

 &lt;span class="err"&gt;   &lt;/span&gt;&lt;span class="nx"&gt;fun&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

 &lt;span class="err"&gt;   &lt;/span&gt;&lt;span class="k"&gt;return&lt;/span&gt; 

 &lt;span class="err"&gt;   &lt;/span&gt;&lt;span class="nx"&gt;z&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="nx"&gt;fun&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;bugJS&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;77&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt;

&lt;span class="c1"&gt;//it leads to undefined error&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Running the above function will lead to an undefined error. &lt;/p&gt;

&lt;p&gt;Here is how the interpreter executes the code:&lt;/p&gt;



&lt;div class="highlight"&gt;&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nx"&gt;bugJS&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;z&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;

 &lt;span class="err"&gt;   &lt;/span&gt;&lt;span class="kd"&gt;var&lt;/span&gt;

 &lt;span class="err"&gt;   &lt;/span&gt;&lt;span class="nx"&gt;fun&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

 &lt;span class="err"&gt;   &lt;/span&gt;&lt;span class="k"&gt;return&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="c1"&gt;//semicolon inserted here automatically&lt;/span&gt;

 &lt;span class="err"&gt;   &lt;/span&gt;&lt;span class="nx"&gt;z&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="nx"&gt;fun&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;bugJS&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;77&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt;

&lt;span class="c1"&gt;//it leads to undefined error&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Since the interpreter will automatically insert a semicolon at the end of the line of the return statement, it will lead to an undefined error. &lt;/p&gt;

&lt;p&gt;This also illustrates why ending JavaScript statements with semicolons is important. &lt;/p&gt;

&lt;h2&gt;
  
  
  5. Other causes of JavaScript bugs
&lt;/h2&gt;

&lt;p&gt;Lastly, the study found out that other JavaScript programming mistakes lead to 9% of all errors and faults in JavaScript code. &lt;/p&gt;

&lt;p&gt;For example, a common cause of errors in this category is neglecting the differences in browsers when developing applications. &lt;/p&gt;

&lt;p&gt;With the availability of various web browsers, which interpret JavaScript code differently, it is essential for developers to ensure that their applications can run smoothly in the different browsers. &lt;/p&gt;

&lt;p&gt;Otherwise, if your code cannot work comfortably across the major browsers, your applications may not meet the needs of the intended audience.&lt;/p&gt;

&lt;p&gt;For example, the new JavaScript arrow function, which is supported by most modern browsers, cannot work on the good old Internet Explorer browser.&lt;/p&gt;

&lt;p&gt;Here is an example of an arrow function:&lt;/p&gt;



&lt;div class="highlight"&gt;&lt;pre class="highlight javascript"&gt;&lt;code&gt;
&lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;colors&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;blue&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;white&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;red&lt;/span&gt;&lt;span class="p"&gt;];&lt;/span&gt;

&lt;span class="nx"&gt;colors&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;forEach&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;values&lt;/span&gt; &lt;span class="o"&gt;=&amp;amp;&lt;/span&gt;&lt;span class="nx"&gt;gt&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;values&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt;

&lt;span class="c1"&gt;//blue&lt;/span&gt;

&lt;span class="c1"&gt;//white&lt;/span&gt;

&lt;span class="c1"&gt;//red&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;If you want to ensure that your JavaScript programs are error-free, you need to understand how the quirks of the language work. &lt;/p&gt;

&lt;p&gt;And, the best way to master the intricacies of the language is to build real applications using projects offered by &lt;a href="https://www.liveedu.tv/guides/programming/javascript/"&gt;LiveEdu&lt;/a&gt;. &lt;/p&gt;

&lt;p&gt;With practice (and lots of it), you’ll be able to build amazing web applications that improve the user experience. &lt;/p&gt;

&lt;p&gt;Happy bug-free JavaScript coding!&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>bugs</category>
      <category>webprogramming</category>
      <category>study</category>
    </item>
  </channel>
</rss>
