<?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>DEV Community: kamaldeen olaide, LAWAL.</title>
    <description>The latest articles on DEV Community by kamaldeen olaide, LAWAL. (@kamaldeenlawal).</description>
    <link>https://dev.to/kamaldeenlawal</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%2F791830%2F36fe74ff-f3a7-4958-81b6-d4e819893494.jpg</url>
      <title>DEV Community: kamaldeen olaide, LAWAL.</title>
      <link>https://dev.to/kamaldeenlawal</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/kamaldeenlawal"/>
    <language>en</language>
    <item>
      <title>Why are Feature Flags Important for Your Deployment Strategy?</title>
      <dc:creator>kamaldeen olaide, LAWAL.</dc:creator>
      <pubDate>Thu, 21 Dec 2023 21:49:21 +0000</pubDate>
      <link>https://dev.to/kamaldeenlawal/why-are-feature-flags-important-for-your-deployment-strategy-3ab8</link>
      <guid>https://dev.to/kamaldeenlawal/why-are-feature-flags-important-for-your-deployment-strategy-3ab8</guid>
      <description>&lt;p&gt;One of the tasks of being a junior software engineer in my team is to write reusable code that meets the software requirements. Hence, the DevOps team will work on deploying the software and automating the process.&lt;/p&gt;

&lt;p&gt;In this post, we’ll look into the deployment strategy and the difference between a conventional and modern method of deployment strategy. We’ll also look at the importance of feature flags in deployment strategies.&lt;/p&gt;

&lt;p&gt;Additionally, we’ll also look at feature flags for dark launching, canary release, and new features.&lt;/p&gt;

&lt;h2&gt;
  
  
  Understanding Deployment Strategy
&lt;/h2&gt;

&lt;p&gt;What is &lt;strong&gt;Deployment Strategy&lt;/strong&gt;? Deployment strategy in IT operations and software development is a set of techniques adopted by DevOps teams. This helps them update and release software applications in a very reliable condition.&lt;/p&gt;

&lt;p&gt;In my company's case, systems get delivered without errors with little or no downtime to the end-users.&lt;/p&gt;

&lt;h2&gt;
  
  
  The difference between a conventional  and “Modern” method of Deployment Strategies
&lt;/h2&gt;

&lt;p&gt;There are two main known deployment strategies for updating a system and releasing software. They are the traditional method and the modern method of deployment strategies.&lt;/p&gt;

&lt;h3&gt;
  
  
  Conventional or Traditional Deployment Strategies.
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Waterfall Model&lt;/strong&gt;: This strategy has some characteristics which include but are not limited to sequential phases, comprehensive documentation, and limited flexibility among others. It is not a deployment strategy per se, but a traditional software development approach. Waterfall in the realm of deployment simply means each phase like the development, testing, and quality assurance phases must come before deployment.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Big-Bang Deployment:&lt;/strong&gt; This strategy encompasses all changes, and hence, rolls out all the changes at a go without any incremental updates.&lt;/p&gt;

&lt;h3&gt;
  
  
  Modern Method of Deployment Strategies
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Continuous Integration/Continuous Deployment (CI/CD)&lt;/strong&gt;:  This is one of the modern methods of deployment. A method where any changes to a code are constantly integrated into a repository by large team members, and subsequently deploy the code changes to production.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Cloud-based Deployment&lt;/strong&gt;: With cloud-based deployment, cloud computing services like Amazon Web Services (AWS), and Google Cloud Platform are used for the implementation of strategies as required by your specific needs.&lt;/p&gt;

&lt;h3&gt;
  
  
  Importance of Features Flags in Deployment Strategies
&lt;/h3&gt;

&lt;p&gt;With feature flags, my company software and DevOps teams have total control of specific features on either a website or in a software application.&lt;br&gt;
It reduces the risk of introducing bugs to the software by the software team, by allowing the software team to incrementally release new features, as well as selective releases of the feature to a specific user base.&lt;/p&gt;

&lt;h2&gt;
  
  
  Feature Flag in Deployment Strategy as a Risk Mitigation Tool
&lt;/h2&gt;

&lt;p&gt;Having explained both the deployment strategy and the feature flags. Let's now explore why the feature flag serves as a risk mitigator during deployment strategy.&lt;/p&gt;

&lt;p&gt;Risk mitigation during deployment strategy is identifying, minimizing, or eliminating risks that are bound to happen. Especially, during software application deployment.&lt;/p&gt;

&lt;p&gt;While it’s difficult to identify all issues during deployment. It is a key concept to manage risk for smooth, and seamless deployment.&lt;/p&gt;

&lt;h3&gt;
  
  
  Feature flags help to serve as a mitigation tool in several ways
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Measured Rollout&lt;/strong&gt;: Risk mitigation is identifying risk before deployment. Feature flags allow you the opportunity to test your new functionality with a controlled subset of users in a limited exposure environment. With this, the impact of issues, if there are any, gets confined to a smaller group of users.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Flexible Rollback&lt;/strong&gt;: Feature flags provide an instant ability to undo a change when critical or unexpected issues occur during development. This flexible rollback enhances customer satisfaction because it minimizes the risk of extended downtime.&lt;/p&gt;

&lt;h2&gt;
  
  
  Feature Flags in Deployment Strategy for User Personalization
&lt;/h2&gt;

&lt;p&gt;User personalization in deployment strategy is the process of personalizing software applications to a specific individual user. This is a strategy employed by us to improve user experience and enhance user retention.&lt;/p&gt;

&lt;h3&gt;
  
  
  Feature flags help with User Personalization in Several Ways
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Gradual Rollout:&lt;/strong&gt; Feature flags help in user personalization by allowing developers to watch the performances of the features gradually released to a distinct set of users. This empowers the developers to increase the testing sample of users with the feature, because of the stability of the feature.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Instant Rollbacks&lt;/strong&gt;: Feature flags allow developers without waiting for the full deployment to revert to the status quo if the newly baked user personalization feature produces an unwanted or unexpected issue that may lead to a bad user experience.&lt;/p&gt;

&lt;h2&gt;
  
  
  Feature Flags in Deployment Strategy for Parallel Development
&lt;/h2&gt;

&lt;p&gt;In my team’s example, parallel deployment is the strategy we employed to compare and contrast vital information like functionality, and performance between the previous and the new version of the system application&lt;/p&gt;

&lt;p&gt;Parallel deployment also known as parallel development is a software deployment strategy that reduces downtime, risk of failures, and errors. By allowing the gradual transition from the previous version to the new version of the software application.&lt;/p&gt;

&lt;h3&gt;
  
  
  Feature flags help for Parallel Development in Several Ways
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Reduction in Merge Conflic&lt;/strong&gt;ts: Feature flags help reduce merge conflicts that arise from parallel development. Most especially if there are many developers on a codebase. By enabling a flag, where each developer can work on their features. Feature flags mitigate the issue of merge conflicts.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Reduction in Time-to-Market&lt;/strong&gt;: Feature flags fastrack the time-to-market for new features. This enables the deployment of a feature despite having several developers working on many features before the other parallel efforts are completed.&lt;/p&gt;

&lt;h2&gt;
  
  
  Feature Flags in Deployment Strategy for Continuous Integration and Continuous Development (CI/CD)
&lt;/h2&gt;

&lt;p&gt;The integration of code changes into a shared repository, and deployment of the system application is achievable through Continuous Integration and Continuous Development for continuous testing of the software.&lt;/p&gt;

&lt;h3&gt;
  
  
  Feature flags help for Continuous Integration and Continuous Development in Several Ways
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Incremental Rollouts:&lt;/strong&gt; Feature flags allow for the deployment of features incrementally under a feature flag, to gradually expose the feature to a specific set of users.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Risk Reduction:&lt;/strong&gt; Feature flags help in identifying and addressing issues at the early stage of development. With the bit-by-bit release of the features. This allows for the risk reduction associated with deploying changes at a stretch.&lt;/p&gt;

&lt;h2&gt;
  
  
  Feature Flags in Deployment Strategy for Emergency Response
&lt;/h2&gt;

&lt;p&gt;Emergency response is a deployment strategy for combating and addressing unannounced critical situations. This kind of strategy is mostly employed by government agencies and some emergency service providers. Feature flags help the organization to adequately respond to unforeseen circumstances.&lt;/p&gt;

&lt;h3&gt;
  
  
  Feature flags help in Deployment Strategy for Emergency Response in Various Ways
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Recovery:&lt;/strong&gt; Feature flags help in the recovery process immediately after the response stage. They can reintroduce features as the situation is brought under control, and iterating based on the needs of the respondent.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Top-Notch Security&lt;/strong&gt;: Feature flags allow for prompt disabling of potentially exploitable features. That in turn combats the effect of the attack environment.&lt;/p&gt;

&lt;h2&gt;
  
  
  Features Flags for Dark Launching
&lt;/h2&gt;

&lt;p&gt;Dark launching is the process of releasing a specific feature and taking its functionality to a segment of your users. It is also the less exposure of traffic of code deployed to the production environment.&lt;/p&gt;

&lt;p&gt;Take my company as an example, dark launching is the release that allows our DevOps teams to fix bugs, access performance metrics, and gather feedback from the user about the feature.&lt;/p&gt;

&lt;p&gt;The practical way to use dark launch is through feature flags, that allow the DevOps team to control both the visibility and availability of the new feature without deploying the code.&lt;/p&gt;

&lt;p&gt;My team DevOps teams use dark launching to test new features on a segment of their user base. This opportunity is unlike the traditional method of releasing a risky-prone feature.&lt;/p&gt;

&lt;h3&gt;
  
  
  Pros of Dark Launching with Feature Flags
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Real-time Control:&lt;/strong&gt; Dark launching can start and finish the lifecycle of a feature with the help of a feature flag. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Continuous Deployment&lt;/strong&gt;: Dark launching separates feature release from feature development with continuous deployment. It is easy to test new and existing features concurrently without disrupting the user experience.&lt;/p&gt;

&lt;h2&gt;
  
  
  Features Flags for Canary Release
&lt;/h2&gt;

&lt;p&gt;Canary release is a release strategy employed for testing a newer version of an application in a real-world environment to gather feedback before making it available to a wider section of users. &lt;br&gt;
Our  DevOps team tests the feature stability by setting up the updated feature and shifting the production traffic from the old version of the feature to the updated features.&lt;/p&gt;

&lt;h3&gt;
  
  
  Feature Flags with Canary Release
&lt;/h3&gt;

&lt;p&gt;Feature flags help in implementing canary release with its value set to off, this ensures no users have access to the new feature.&lt;br&gt;
With a feature management platform like Unleash, the feature flags test the new features with a small percentage of users. The team can include beta testers or internal teams.&lt;br&gt;
Proper monitoring of the performance metrics and feedback from the release, and an instant turn-off of the feature flags if issues are detected.&lt;/p&gt;

&lt;h3&gt;
  
  
  Pros of Canary Release with Feature Flags
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Quick Iteration:&lt;/strong&gt; Feature flags with the help of performance metrics, and feedback from users enable quick adjustments to the software application.&lt;br&gt;
&lt;strong&gt;A/B Testing:&lt;/strong&gt; Feature flags helps in comparing the performance and user engagement of distinct feature variation. This process is known as the A/B testing.&lt;/p&gt;

&lt;h2&gt;
  
  
  Features Flags for New Features
&lt;/h2&gt;

&lt;p&gt;New features are an innovative approach to improve the speed, flexibility, and efficiency of software deployments. It is a new innovative approach or methodology that enhances the software deploying process.  &lt;/p&gt;

&lt;p&gt;New features require meticulous planning and execution for any organization that hopes to deliver high-quality software to its users while maintaining the ability to adapt to business needs.&lt;/p&gt;

&lt;h3&gt;
  
  
  Pros of New Feature with Feature Flags
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Speed&lt;/strong&gt;: Feature flags help the new feature to be fast in improving the software deployments.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Flexibility:&lt;/strong&gt; Feature flags enable the new feature to be flexible which enhances the software development.&lt;/p&gt;

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

&lt;p&gt;So, now you understand deployment strategy and the difference between traditional and modern methods of deployment. We have also discussed the importance of feature flags in deployment strategies, as well as the feature flags for dark launching, canary release, and new features.&lt;/p&gt;

</description>
      <category>frontend</category>
      <category>webdev</category>
      <category>beginners</category>
    </item>
    <item>
      <title>Beginner's Guide To Array In JavaScript.</title>
      <dc:creator>kamaldeen olaide, LAWAL.</dc:creator>
      <pubDate>Fri, 12 Aug 2022 18:53:00 +0000</pubDate>
      <link>https://dev.to/kamaldeenlawal/ultimate-guide-to-array-in-javascript-2803</link>
      <guid>https://dev.to/kamaldeenlawal/ultimate-guide-to-array-in-javascript-2803</guid>
      <description>&lt;h2&gt;
  
  
  Ultimate Guide To Array In JavaScript
&lt;/h2&gt;

&lt;p&gt;Let’s look at important data structures we have in JavaScript. Array and iterables will be looked on in this article. We will cover ways of creating array(s), how to manipulate array and some of the important array methods.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What is an array?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;An array in JavaScript is zero-indexed based and a collection of ordered lists of an element specified by index. An array doesn’t have a fixed length and can store any values of different types, ranging from string, Boolean, and number, to object and array itself.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Iterables vs. Array-like Objects&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;**Iterables **in JavaScript can be defined as any objects with @@ itearable method that also implements the iterable protocol. And most importantly, it is an object that can be looped through with a for-of-loop.&lt;/p&gt;

&lt;p&gt;Some of the examples of iterables are NodeList, Map, Set, and String, and not every iterable is an array.&lt;/p&gt;

&lt;p&gt;**Array-like **are objects that use indexes to access items and have a length property. Examples of array-like objects are String and NodeList, and not all array-like objects are arrays.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Creating Arrays&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;There are a couple of ways of creating arrays in JavaScript. They are as follows:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Creating with a square bracket notation [];&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;This is by far the most popular, easy, and recommended way of creating an array in JavaScript.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--lnWdulhT--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/2000/0%2A8Ygp4eV8LPKC7BQX" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--lnWdulhT--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/2000/0%2A8Ygp4eV8LPKC7BQX" alt="" width="586" height="330"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;From the above code, an array of numbers was created using the [] method, and inside the code, you separate the values by comma and end the code with a semicolon;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Creating an array with a special keyword new and array()&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;This method uses a constructor function, and it builds a new array.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--3WB-3ScE--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/2000/0%2AR0zIM6ZUOd-W0NMZ" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--3WB-3ScE--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/2000/0%2AR0zIM6ZUOd-W0NMZ" alt="" width="772" height="330"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The above code will produce an array of numbers with two values of each number inside it, but it gets strange if we pass one value in the array and the result will be the below result.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--DMXFYV84--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/2000/0%2A7NbUa12N1TprcRkm" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--DMXFYV84--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/2000/0%2A7NbUa12N1TprcRkm" alt="" width="736" height="114"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;We then get an empty array with a length of 9. We can also remove the special new keyword and the array will work perfectly.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Creating an array with Array.of();&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;This method of creating an array is a special method of of() on the globally available array objects in JavaScript.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Ke37MBd5--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/2000/0%2AB440pD0fYkRv9aGm" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Ke37MBd5--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/2000/0%2AB440pD0fYkRv9aGm" alt="" width="553" height="71"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The above code is created with the Array.of() method of creating an array.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Creating an array with Array.from()&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Array.from() is special because it doesn’t take multiple numbers like the above mentioned ways of creating an array. If you do, it will give an error as the output.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--fUXvP6P6--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/2000/0%2A4IE40GZM6cKIWt-7" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--fUXvP6P6--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/2000/0%2A4IE40GZM6cKIWt-7" alt="" width="777" height="121"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The above code shows an error when multiple arguments are passed through an Array.from(); instead, it takes an array-like object or an iterable, which is not a real array and converts it to a real array.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Zdgz0o3K--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/2000/0%2ACC74wWMb-GwAnXPL" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Zdgz0o3K--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/2000/0%2ACC74wWMb-GwAnXPL" alt="" width="747" height="92"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Adding and removing elements from an array&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;PUSH()&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;One of the methods of adding data to an array in JavaScript is the push() method.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--3ae4DtHm--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/2000/0%2As_Zuz2F5EQKmQkfF" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--3ae4DtHm--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/2000/0%2As_Zuz2F5EQKmQkfF" alt="" width="800" height="343"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The above code shows that reading was added to the end of an array of favorites with the help of the push() method.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;UNSHIFT()&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Unshift() is an array method used to add elements to the beginning of an array.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--2lc_TDjK--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/2000/0%2AHb3zRXj0uM8iuI9x" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--2lc_TDjK--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/2000/0%2AHb3zRXj0uM8iuI9x" alt="" width="800" height="442"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;POP()&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Pop() is used to pop or remove the last element from an array.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--DV6nECMp--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/2000/0%2ApacVHka43YRCKCWP" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--DV6nECMp--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/2000/0%2ApacVHka43YRCKCWP" alt="" width="800" height="442"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Pop() doesn’t return the element it removes.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;SHIFT()&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Shift() is an array method used to remove the first element. It is similar to pop() but removes the first element of an array.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--TuMhpoXC--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/2000/0%2A3TMsyi0unFvXILdW" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--TuMhpoXC--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/2000/0%2A3TMsyi0unFvXILdW" alt="" width="800" height="407"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;We can as well add/replace an element inside an array with the direct index access.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;SPLICE()&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Splice() is a special method only available on real arrays, not on array-like or iterable objects. It is used to insert an element between two elements in an array. There are two different versions of the splice method; one takes at least two arguments while the other takes more than two arguments.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--zz36BZVi--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/2000/0%2ABNxUhiiFqAbMRZzH" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--zz36BZVi--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/2000/0%2ABNxUhiiFqAbMRZzH" alt="" width="800" height="348"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The above code shows a splice method with more than two arguments. The first argument is for specifying the start index, amount of item you want to delete is the second argument, while the third argument is what you want to insert into the element. Start at index zero, delete no items, and insert kunle into the array.&lt;/p&gt;

&lt;p&gt;Splice can also be used for the deletion of items in an array.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--IJ2Vbq0q--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/2000/0%2AWtcJByJwzYUBJiLx" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--IJ2Vbq0q--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/2000/0%2AWtcJByJwzYUBJiLx" alt="" width="800" height="397"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The above code shows splice with two arguments and is used for the deletion of an item. The first argument is the starting index, while the second argument specifies the number of items to delete.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;SLICE()&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--PVeoLxq7--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/2000/0%2Ai4PWmYmf3PXQFE5l" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--PVeoLxq7--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/2000/0%2Ai4PWmYmf3PXQFE5l" alt="" width="800" height="197"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The above code shows an array with sliceMethod was created with 7 items. Then, storedResult was assigned to that created array.&lt;/p&gt;

&lt;p&gt;The new element was pushed to the sliceMethod array, and when we console.log the output, the storedResult has the new element pushed to sliceMethod. This is the normal behavior of an object because it is a reference type, but with the slice method, we can copy array as a brand new array based on the old array.&lt;/p&gt;

&lt;p&gt;Slice() is one of the methods we can use on a real array, just like splice(). It is used to copy an array and return a brand new array.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--P-icTbr4--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/2000/0%2AnNHjgJqMGE9EeMe7" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--P-icTbr4--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/2000/0%2AnNHjgJqMGE9EeMe7" alt="" width="800" height="334"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The above code returns a brand new array, and this is another method of copying an array since an array is, in the end, an object and reference value.&lt;/p&gt;

&lt;p&gt;Slice() can also be used to select ranges of an array, if you want to select more than one element at the same time, but not the entire elements.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--0PxbfHUf--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/2000/0%2APWolm2cB1V9qkKNq" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--0PxbfHUf--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/2000/0%2APWolm2cB1V9qkKNq" alt="" width="800" height="443"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The code above shows that when we use the slice() method on the sliceMeth array, we get the result of the items from index of 1 to index of 4.&lt;/p&gt;

&lt;p&gt;Note that the index of 5 is not included in the result.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;CONCAT()&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;A useful method for adding element to an array and return a brand new array, which will be useful if you want to create a copy an array after adding some element to it is concat() method.&lt;/p&gt;

&lt;p&gt;Concat() method allows us to concatenate/ add element to the end of an array, this is similar to push() method, but with concat(), it takes an array or multiple arrays and combines the new array with the old array. It doesn’t add the new as nested array to the old array but instead, pull out all the element in the new array and passes them to the element in the old array and in turn return a brand new array.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--jo5tBxWw--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/2000/0%2AylsoNfjUoFT4-bdZ" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--jo5tBxWw--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/2000/0%2AylsoNfjUoFT4-bdZ" alt="" width="800" height="431"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;indexOf() lastIndexOf()&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Whenever you have an array of information and want to find out at which indexes in the array a certain element sits, you can either replace it or do whatever you feel like doing to that element.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--KeBaoY_K--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/2000/0%2A2RZk6VQpZppyGfwm" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--KeBaoY_K--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/2000/0%2A2RZk6VQpZppyGfwm" alt="" width="800" height="515"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;indexOf() method will return the value of an element in an array. The output for the above code is 2. If you have the same value more than once in an array, indexOf() will return the first value alone.&lt;/p&gt;

&lt;p&gt;lastIndexOf() is used to search for an element within an array from the right side of the array.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--X2XdcNh2--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/2000/0%2AToHnl9HzvBGzeI0K" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--X2XdcNh2--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/2000/0%2AToHnl9HzvBGzeI0K" alt="" width="800" height="474"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The above code shows that lastIndexOf() of the value 0 returns 6.&lt;/p&gt;

&lt;p&gt;Note: both indexOf() and lastIndex0f() only work on primitive values and not on reference types of values, as the code below shows in detail.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--zGXAta1E--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/2000/0%2AQudffszQHTKkKARE" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--zGXAta1E--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/2000/0%2AQudffszQHTKkKARE" alt="" width="800" height="578"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;find() and findIndex()&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;To find an object in an array is easy with find() and findindex(). They both take an argument that is a function that can accept up to three arguments. The first argument is the single object in the array. The index is the second of that single object, while the third argument is the full array.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--ne2QMEh2--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/2000/0%2AjUnhYM-cJAH4is79" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--ne2QMEh2--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/2000/0%2AjUnhYM-cJAH4is79" alt="" width="800" height="537"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;findIndex() on the other hand will not return the matching item of the array , it will only return the index.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--EpP3_jtB--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/2000/0%2AFFN_H6LXiyoIw6iG" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--EpP3_jtB--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/2000/0%2AFFN_H6LXiyoIw6iG" alt="" width="800" height="513"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;INCLUDES()&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The includes() method is used to check if an element is part of an array, though it is mostly useful for primitive values because it is used to check values only.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--KACycZCy--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/2000/0%2AGUU5omnR3rUdGyDe" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--KACycZCy--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/2000/0%2AGUU5omnR3rUdGyDe" alt="" width="800" height="481"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The above code shows the output as true because it is included in the array.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;FOREACH()&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;forEach() is an alternative to for of loop in JavaScript, it takes a function, and the function takes up to three arguments.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--uywWuk3p--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/2000/0%2AmcfQY0s_e7s9MfXi" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--uywWuk3p--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/2000/0%2AmcfQY0s_e7s9MfXi" alt="" width="800" height="406"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The above code shows the forEach() method in action. The first argument is the singular element in the array, the second argument is the index of the array, while the third argument is all the elements in the array if you need them. This enables us to have access to the indexes of the array, unlike using a for of loop.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;MAP()&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Map() is one of the special methods available on a real array. It has the task of taking an array, running a function on every item in the array, and the function will now return a transformed element for every element in the array.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--hf_aRThj--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/2000/0%2AWBbdfP0b0QinEh5m" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--hf_aRThj--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/2000/0%2AWBbdfP0b0QinEh5m" alt="" width="800" height="610"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Map() is a really nice method of transforming an array because it makes changing an element and getting a brand new array based on the changed element super easy.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;SORT() and REVERSE()&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Sort() is used to sort an element in an array. By default, sort() converts every element in an array to a string and sorts this in a string logic where 2 is smaller than 4. It takes a compare function that takes two numbers and executes this function on the pairs of elements.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--_d2iIi9j--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/2000/0%2AKw1_Q7xHouPOMZX5" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--_d2iIi9j--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/2000/0%2AKw1_Q7xHouPOMZX5" alt="" width="800" height="484"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The above code shows that the elements in the array were sorted in descending order.&lt;/p&gt;

&lt;p&gt;reverse() is similar to the sort method as it returns the elements of the array in ascending order.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--o8rB3a-O--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/2000/0%2AfU2MI7kCld2Ah9FG" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--o8rB3a-O--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/2000/0%2AfU2MI7kCld2Ah9FG" alt="" width="800" height="484"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;FILTER()&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;filter() allows us to filter the elements in an array. Just like other high-order array methods like sort, forEach, map, and find, it takes a function which allows us to reduce the number of elements of an array based on some filter.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--OzMwihUu--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/2000/0%2AUz3dFwxd10dhuW5B" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--OzMwihUu--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/2000/0%2AUz3dFwxd10dhuW5B" alt="" width="800" height="388"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;REDUCE()&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Reduce() is one of the most complex and challenging methods in JavaScript. It is used to sum up the elements in an array. It reduces an array to a simpler value.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Ozuls_kF--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/2000/0%2ACUjXhah5geEUKtHL" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Ozuls_kF--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/2000/0%2ACUjXhah5geEUKtHL" alt="" width="800" height="277"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The above code shows the arguments as previousvalue, currentvalue, currentindex, and the arrays. It also takes another optional argument which serves as the initial value to start with.&lt;/p&gt;

&lt;p&gt;The previousvalue will be the initial value, while the first element of the array will serve as the currentvalue.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Spread Operator (…)&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The spread operator is an operator that pulls out all the elements of an array and gives them to you as a standalone list of elements.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--kIA5niuJ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/2000/0%2APYChEy6c8j4w4zVE" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--kIA5niuJ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/2000/0%2APYChEy6c8j4w4zVE" alt="" width="800" height="578"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Array Destructuring&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--C0fsOR3x--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/2000/0%2A8747Mmgn1s9CmwlT" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--C0fsOR3x--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/2000/0%2A8747Mmgn1s9CmwlT" alt="" width="800" height="397"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Array destructuring is a powerful and nice syntax feature used to pull out elements from an object, array included. You begin array destructuring by inserting a square bracket on the left side of the equal sign and pointing to your array; whatever you enter in the square bracket will serve as the variable name for the array on the right side.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Conclusion&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;In conclusion, we have looked at arrays and iterables, covered ways of creating arrays (s), how to manipulate arrays and some of the important array methods.&lt;/p&gt;

&lt;p&gt;In this guide, we briefly talked about the popular spread operator and array destructuring.&lt;/p&gt;

&lt;p&gt;Happy coding..&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>webdev</category>
      <category>beginners</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>Beginner’s guide to JavaScript DOM</title>
      <dc:creator>kamaldeen olaide, LAWAL.</dc:creator>
      <pubDate>Sun, 31 Jul 2022 16:28:00 +0000</pubDate>
      <link>https://dev.to/kamaldeenlawal/beginners-guide-to-javascript-dom-25gh</link>
      <guid>https://dev.to/kamaldeenlawal/beginners-guide-to-javascript-dom-25gh</guid>
      <description>&lt;h2&gt;
  
  
  Beginner’s guide to JavaScript DOM
&lt;/h2&gt;

&lt;p&gt;In this article, we will learn about the JavaScript DOM, nodes and elements, querying and traversing the DOM, evaluating and manipulating DOM nodes, and how we can add and remove an element.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The Document Object Model (DOM)&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The Document Object Model (DOM) is the heart of any web manipulation, created by the browser when an HTML document loads inside it.&lt;/p&gt;

&lt;p&gt;The Document Object Model (DOM) is a built-in object with many properties and methods for manipulating content, styles, and structures. is one of the unique and useful tools in JavaScript. Interacting with the browser, reacting to user events, changing CSS styles, making cool popups, and many other things can be achieved through the DOM.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;DOM and how it’s created.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The DOM describes an HTML page as a hierarchy of nodes; it parses the HTML codes and creates an object representation of it, where the HTML tag/element is translated to an element node and text/whitespace are translated to text node, because the browser doesn’t work with text behind the scenes.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;JavaScript Vs Browser.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;JavaScript and the browser are always in communication, with the browser being in charge of parsing, rendering, and loading HTML/JavaScript scripts when they are &lt;a href="http://downloaded.As"&gt;downloaded. As&lt;/a&gt; we all know, JavaScript is a hosted language where the browser provides the environment for effective running of JavaScript. The browser provides a bunch of APIs and functionality to enable JavaScript to work with the parsed documents.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;DOM API&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The majority of web APIs (DOM API Included) are written in JavaScript with the sole aim of manipulating the DOM of web documents.&lt;/p&gt;

&lt;p&gt;The API is generally known as “Application Programming Interfaces,” which serves as the path between the rendered HTML documents and the JavaScript. It has collections of interfaces, properties, and methods, and is made up of code structures for manipulating the functionality of an application by developers.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The Difference between Nodes and Elements&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Everything in the DOM is simply a node. Nodes are generally the objects that make up the DOM. Elements/Element nodes are HTML tags in the DOM, text nodes are text and whitespace in the DOM, while attributes create attribute nodes.&lt;/p&gt;

&lt;p&gt;Nodes and elements are somehow used interchangeably in the DOM, but there is a difference between them.&lt;/p&gt;

&lt;p&gt;**Elements **are simply one type of node available in the DOM, created from an HTML tag rendered without the text. It consists of some special properties and methods to interact with elements by either changing the style, content or by creating or removing the element. Node is both an element and a text node.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Our Sample Code&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--N6i2pAba--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/2000/0%2A3_cG1pxiDK8NnMcl" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--N6i2pAba--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/2000/0%2A3_cG1pxiDK8NnMcl" alt="" width="800" height="671"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--lzAHoOaF--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/2000/0%2A1MKAUr4pWkEEPSbq" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--lzAHoOaF--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/2000/0%2A1MKAUr4pWkEEPSbq" alt="" width="788" height="2458"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Selecting/Querying of Nodes.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;There are many methods of selecting and querying nodes in your rendered HTML page in the DOM.&lt;/p&gt;

&lt;p&gt;They are as follows.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;querySelector().&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;querySelectorAll().&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;getElementById().&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;getElementsByTagName().&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;getElementByClassName().&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;ol&gt;
&lt;li&gt;querySelector(). With querySelector(), you can have access to a single element in the DOM. This method gives you more flexibility and power as it can take CSS selectors and pseudo selectors as you can use it in a CSS file.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--0Lt8Pf7h--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/2000/0%2A0wBn8zzv1cmFPCsS" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--0Lt8Pf7h--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/2000/0%2A0wBn8zzv1cmFPCsS" alt="" width="800" height="99"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Using document.querySelector() to access the first elements in the DOM is recommended.&lt;/p&gt;

&lt;p&gt;This method can also be used to uniquely select the first instances, i.e., it takes any CSS selectors and will return the first element if there are selectors that match multiple elements. Despite the fact that all the li tags in our code have a class of listItem, it will return the first li alone.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;querySelectorAll () This method is used if your wish is to access a collection of elements, an array like object, which is typically a node list, not a real array, but an array like object that supports certain behaviors of an array. You also have different ways of querying the documents by CSS selectors and pseudo selectors, which will return a non-live nodelist.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--IwQM3Q02--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/2000/0%2AckWJEsYV2hG2QtJc" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--IwQM3Q02--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/2000/0%2AckWJEsYV2hG2QtJc" alt="" width="800" height="183"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;getElementById(). This method is the easiest way to find an element inside a DOM tree and will return a single element as Id is a unique way of assigning an attribute to an element.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The below code snippet shows the result of a unique way of selecting an Id of vp from our code.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--CYrPUjYL--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/2000/0%2ABo2acKml97edUvTn" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--CYrPUjYL--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/2000/0%2ABo2acKml97edUvTn" alt="" width="800" height="144"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;getElementsByTagName() this method is used to access elements with similar tag names. It returns an HTML collection instead of a Nodelist like querySelectorAll(), and it will return a live Nodelist.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--zXY40K5g--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/2000/0%2Ad2MCQZaI4KlVYKes" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--zXY40K5g--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/2000/0%2Ad2MCQZaI4KlVYKes" alt="" width="796" height="298"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;getElementsByClassName(). This method will retrieve elements with similar class names into an HTML collection.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--kMo4j76b--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/2000/0%2AJp7ROXOICryzZ_dw" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--kMo4j76b--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/2000/0%2AJp7ROXOICryzZ_dw" alt="" width="800" height="304"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The below code shows the result of selecting the className of all the li in our code sample.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;DOM element evaluation and manipulation&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;There are many ways to manipulate and evaluate elements in the DOM, provide a good user experience for the users, change and modify the text of an element in the rendered user interface without the need to reload the page. The following are some of the methods of manipulating and evaluating elements in the DOM.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;innerText&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;innerHTML&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;textContent&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;innerText; This is one of the methods of accessing and modifying text in the DOM. It displays the invisible text contained inside the node. Code below for more illustrations.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--uaCcvnpT--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/2000/0%2AFBGBmdt3mcN4lXTu" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--uaCcvnpT--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/2000/0%2AFBGBmdt3mcN4lXTu" alt="" width="800" height="122"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The above code shows the result for the innerText of the first li with an Id of fab. Note that I added span to the first li from our sample code.&lt;/p&gt;

&lt;p&gt;InnerHTML; with this method, the text content and element spacing are returned, and the entire HTML element can be added into your DOM. The example below shows where the h2 element was added/appended to our sample code with the help of innerHTML.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--a98biUdA--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/2000/0%2A02sXAywidN38GL-n" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--a98biUdA--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/2000/0%2A02sXAywidN38GL-n" alt="" width="636" height="143"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;textContent; this method gets the inner text as it was in the source code. It won’t return the tags but will return all spacing and hidden CSS text.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--ombXD-Lo--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/2000/0%2Ayye7NpkAzIYqCuH1" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--ombXD-Lo--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/2000/0%2Ayye7NpkAzIYqCuH1" alt="" width="800" height="318"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The above code replaces the text content, otherwise known as a text node, with the new text.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The Difference between Attributes and Properties&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Although not always, attributes are strategically mapped to properties, which enables live synchronization. An attribute is anything written within HTML code that allows the browser to create a DOM object based on the tag name.&lt;/p&gt;

&lt;p&gt;Properties are the value stored in the object that is created based on the HTML code automatically. Objects in JavaScript have properties.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;How to set/remove/get an attribute&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;To change/modify/remove/get an attribute while in the DOM, there are many methods, which are listed below.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;setAttribute() this method is used to set attributes to our specified element. This method takes two values, which are the name of the attributes you want to set (must be a string) and the value you want to give your set attribute.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--skwpOHaj--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/2000/0%2AzjX5VVe36hPXuLrG" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--skwpOHaj--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/2000/0%2AzjX5VVe36hPXuLrG" alt="" width="800" height="346"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;removeAttribute() with this method, attributes can be removed from our HTML element. This method takes only a single value, unlike setAttribute() that takes two values.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--6M9KXBvl--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/2000/0%2As1hANB-Rio38YOCZ" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--6M9KXBvl--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/2000/0%2As1hANB-Rio38YOCZ" alt="" width="800" height="345"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;getAttribute() this method as the name implies, allows for an attribute to be get/retrieve from the HTML code. It takes a single value just like removeAttribute().&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--UeqBwkvd--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/2000/0%2AKaz_s3sJvBhlBWHN" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--UeqBwkvd--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/2000/0%2AKaz_s3sJvBhlBWHN" alt="" width="800" height="289"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Traversing the DOM.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;This section is dedicated to traversing the DOM, where we will discuss some of the properties and methods needed for DOM traversal.&lt;/p&gt;

&lt;p&gt;Traversing the DOM is using one selected node to access either its childrenElement, parentElement, siblingElement or the rest. You can move to any direction in the DOM with the help of traversing. Before we move ahead with traversing the DOM, let’s get hindsight on some of the terms we will encounter.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Child/Children&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;This simply means a direct child node or element node.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Ztew_X7i--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/2000/0%2AjRA-qKd3nP8r32Ob" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Ztew_X7i--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/2000/0%2AjRA-qKd3nP8r32Ob" alt="" width="402" height="152"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In the above code, h1 is the child of div.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Descendant/Descendants&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Descendants are both direct and indirect nodes of an element in the DOM.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--ym1GvVIy--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/2000/0%2AFGQioogPKhednX3Q" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--ym1GvVIy--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/2000/0%2AFGQioogPKhednX3Q" alt="" width="406" height="150"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The above code shows that both the h1 and the sub tag are descendants of the div.&lt;/p&gt;

&lt;p&gt;Parent.&lt;/p&gt;

&lt;p&gt;Just like the child/children, a parent node is a direct parent node or an element.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--FLv86iWL--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/2000/0%2A1gRcRqAktksXlDrc" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--FLv86iWL--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/2000/0%2A1gRcRqAktksXlDrc" alt="" width="365" height="147"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The div is the parent of the h1 but not of the sub tag as shown above.&lt;/p&gt;

&lt;p&gt;Ancestor&lt;/p&gt;

&lt;p&gt;Ancestor is both direct and indirect parent node of an element.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--vzywu24v--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/2000/0%2A88GL5oggkdv5pooG" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--vzywu24v--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/2000/0%2A88GL5oggkdv5pooG" alt="" width="415" height="143"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Div is the ancestor of both the h1 and the sub tag.&lt;/p&gt;

&lt;p&gt;Back to our DOM traversal, we can dive into any surrounding elements or nodes in the DOM once we have selected a node.&lt;/p&gt;

&lt;p&gt;Some of the important properties are as follows.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;parentElement/parentNode&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;childNode/children&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;firstChild/firstElementChild&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;lastChild/lastElementChild&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;nextSibling/nextElementSibling&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;previousSibling/previousElementSibling&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;parentElement/parentNode; the difference between parentElement and parentNode is that while parentElement is used to select an element’s parent node, parentNode is used to select any node in the DOM.&lt;/p&gt;

&lt;p&gt;When there is a need to ascertain the parent element of a particular element that is nested in another, the parentElement property is used.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Y1tBwq3l--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/2000/0%2AM7IzngEcYByIEesE" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Y1tBwq3l--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/2000/0%2AM7IzngEcYByIEesE" alt="" width="618" height="84"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The code returns the above answer when you use parentElement on the li from our sample code.&lt;/p&gt;

&lt;p&gt;childNode/children; the main difference between childNode and children is that while childNode returns all the child nodes in the DOM (text included), children is used to select only the element child node.&lt;/p&gt;

&lt;p&gt;“children” is used to pull out all the nested elements inside the parent element.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--XWfketDc--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/2000/0%2A_LLbqtaLDAsayfrc" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--XWfketDc--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/2000/0%2A_LLbqtaLDAsayfrc" alt="" width="630" height="132"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;All the children were pulled out when children’s property was used on their parent.&lt;/p&gt;

&lt;p&gt;firstChild/firstElementChild; the difference between firstChild/firstElementChild is while firstElementChild returns the first element child alone, firstChild returns the first child node.&lt;/p&gt;

&lt;p&gt;If you have many children nested within a parent and you need to select the first element child, you can use a querySelector to get the first child, but you can as well use the famous firstElementchild to get the result.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--7VZoTv17--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/2000/0%2A5bNMWMoMlEY0FLxX" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--7VZoTv17--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/2000/0%2A5bNMWMoMlEY0FLxX" alt="" width="610" height="82"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;lastChild/lastElementChild; the difference between lastChild/lastElementChild is while lastChild returns the last node, the lasElementChild returns the last element child node.&lt;/p&gt;

&lt;p&gt;If there are many children nested within a parent, and there is a need to select the lastelement child, lastElementchild will get you the result.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--XuJPzq1P--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/2000/0%2Atk9ryKkk1f_MDUAU" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--XuJPzq1P--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/2000/0%2Atk9ryKkk1f_MDUAU" alt="" width="629" height="76"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;nextSibling/nextElementSibling; the difference between nextSibling/nextElementSibling is while nextSibling returns the next sibling node, the nextElementSibling returns the next element sibling node.&lt;/p&gt;

&lt;p&gt;If you wish to select the next sibling element of an already selected element, the property to use is nextElementSibling.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--aIGwZ4VX--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/2000/0%2ADFPZ_rKXTHRVsSK-" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--aIGwZ4VX--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/2000/0%2ADFPZ_rKXTHRVsSK-" alt="" width="628" height="72"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The result from our sample code gives ul as the nextElementSibling to h1.&lt;/p&gt;

&lt;p&gt;previousSibling/nextElementSibling; the difference between previousSibling/previousElementSibling is while previousSibling returns the previous sibling node, the previousElementSibling returns the previous element sibling node.&lt;/p&gt;

&lt;p&gt;If you wish to select the previous sibling element of an already selected element, the property to use is previousElementSibling.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Bf-5mn9Q--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/2000/0%2AP3vi7UThLjojgz6L" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Bf-5mn9Q--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/2000/0%2AP3vi7UThLjojgz6L" alt="" width="623" height="74"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The output of the code that selects the previousElementSibling on the button with a class of .btn from our sample code is the ul.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Query Method vs. DOM Traversal&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;It is super important to be aware of all the DOM traversal techniques, where you can select any element in the DOM. This is powerful, but care must be taken in handling them. Query methods will always work fine in accessing elements in the DOM and you shouldn’t be shy about making use of them.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;DOM Elements Styling&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;specific ways of manipulating elements in the DOM, providing a good user experience to the users, changing and modifying the style of an element is by changing their style.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Style Property&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;style; if you are familiar with CSS properties, we can access the properties in JavaScript and manipulate the styles and change them around using any CSS properties. You can directly target individual CSS styles using an inline method, and this has higher specificity that will override any style properties assigned to the element. From our code sample, I changed the background color of the h1 to blue. example below.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--LS1UWvSv--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/2000/0%2ANZ2nu0CPi60B9RNm" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--LS1UWvSv--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/2000/0%2ANZ2nu0CPi60B9RNm" alt="" width="619" height="127"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Note: When changing styles in JavaScript, instead of using snake case as we use in CSS, the convention is to use a camel case like I did in the above code, which changed from background-color in CSS to backgroundColor in JavaScript. This kind of styling, known as inline, will only work on a single element. If we want to change the background color of all our li tags, as we already gave them the class of listItem, it will not work until we loop through each and apply the style. code below for proper illustration.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--UUTB8JjT--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/2000/0%2AC17lNnVpXSkPLP9A" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--UUTB8JjT--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/2000/0%2AC17lNnVpXSkPLP9A" alt="" width="800" height="355"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Via className&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;With className, you can manipulate the CSS classes attached to an element by dynamically changing, removing, or adding new CSS classes to an element. With className, it takes a single string that contains all the classes to be added. All classes are set and controlled once and other properties like id can be controlled.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--VGlKJrK1--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/2000/0%2AKK8NxmiK2D8EzK0m" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--VGlKJrK1--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/2000/0%2AKK8NxmiK2D8EzK0m" alt="" width="620" height="104"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Via classList&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;classList is a JavaScript object with a couple of built-in methods that make it convenient to add/remove/toggle and check if an element contains a CSS class. It gives you control over the added classes and can also be used in conjunction with className.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Creating/Inserting new Element&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;This section will be dedicated to how a brand new element can be created and inserted into the DOM.&lt;/p&gt;

&lt;p&gt;There are two major ways this can be done; they are as follows:&lt;/p&gt;

&lt;p&gt;1 HTML String&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;creatElement()&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;HTML string can be used to create a new element in the DOM and can be added with innerHTML and insertAdjacentHTML.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;innerHTML&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;innerHTML property which you will find&lt;/strong&gt; on an element node that adds or renders an HTML code in the place you added it. It is useful whenever you plan on changing all the HTML content of an element.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--43HaHfGy--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/2000/0%2AlRQHxZHr8gJQJI4Z" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--43HaHfGy--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/2000/0%2AlRQHxZHr8gJQJI4Z" alt="" width="636" height="143"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;insertAdjacentHTML&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Alternatively, insertAdjacaentHTML which is a method that can be use to add an HTML code next to an existing code instead of replacing the code. it has four positions, beforbegin, afterbegin, beforeend and afterend.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--KDW4OgdE--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/2000/0%2A_2cxMUo0MHt9mPBG" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--KDW4OgdE--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/2000/0%2A_2cxMUo0MHt9mPBG" alt="" width="624" height="171"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;**createElement(); **Method use to create single DOM element node instead of a bunch of HTML at once. createElement() is always called on a document object and takes at least one argument, i.e. the tag name of the element without the angle bracket you want to create.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--mU2xFGbh--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/2000/0%2AyvJXrhaGS9QL1z8c" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--mU2xFGbh--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/2000/0%2AyvJXrhaGS9QL1z8c" alt="" width="800" height="272"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The above code shows a new element li created using the createElement method.&lt;/p&gt;

&lt;p&gt;createElement() object can be added to the DOM with following methods.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;appendChild()/append()&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;prepend(),before(),after(),insertBefore().&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;replaceChild()/replaceWith().&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;**appendChild/append(); **is used to append newly created elements into the DOM. While append() insert both text and element node, appendChild() is used to insert element node only.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--j5PCbq1g--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/2000/0%2A9Vf0uOHE-8dLSkKv" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--j5PCbq1g--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/2000/0%2A9Vf0uOHE-8dLSkKv" alt="" width="800" height="538"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;**prepend(),before(),after(),insertBefore(); **used to insert an element/node in a specific position. Prepend() is used to insert newly craeted element as the fist element, before() is used to insert before a selected element, after() is for inserting of elemnt to a specific position after a selected element, while insertbefore is used to insert a child node before an existing child.&lt;/p&gt;

&lt;p&gt;*&lt;em&gt;replaceChild () or replaceWith () replaceWith *&lt;/em&gt;() is used to replace an entire element in the DOM.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--M3ZVts_x--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/2000/0%2AoCFMEiB6miLAgIjD" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--M3ZVts_x--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/2000/0%2AoCFMEiB6miLAgIjD" alt="" width="800" height="459"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;DOM Node Cloning&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Inserting of element will only move and not copy the element, if you want to copy the element the method available on every node element is the cloneNode(), which takes one optionally argument that is a boolean which determines whether the cloning is a deep when you input true or notify the input is false.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Removing Elements&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;It is nice to have an element inserted into the DOM, but it will be bad if we can’t remove unwanted elements from our DOM. Yes, with replaceWith() we can remove the element but to only replace it with another element. To get rid of an element entirely, there are remove() and removeChild() methods.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--ALM7Md6Y--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/2000/0%2AeOlhm2hYxaE-laqe" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--ALM7Md6Y--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/2000/0%2AeOlhm2hYxaE-laqe" alt="" width="800" height="334"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The above code will remove the ul in our sample code.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--0dz4sqk---/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4u2uvus6xtoaqptcqohd.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--0dz4sqk---/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4u2uvus6xtoaqptcqohd.png" alt="Image description" width="800" height="329"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The above code shows how to use removeChild() .&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Conclussion&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;That is a wrap.&lt;/p&gt;

&lt;p&gt;We have covered so much in this article, we have touched on virtually all the important DOM manipulation properties and methods. We talked about the selection methods, traversing the DOM, creation, insertion, and deletion of elements, and many more.&lt;/p&gt;

&lt;p&gt;I hope this article will help you to get a clear picture of the JavaScript DOM.&lt;/p&gt;

&lt;p&gt;Enjoy your day.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Read this post and more on my &lt;a href="https://typeshare.co/kamaldeenolaidelawal/posts/beginners-guide-to-javascript-dom"&gt;Typeshare Social Blog&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>webdev</category>
      <category>web3</category>
      <category>beginners</category>
    </item>
    <item>
      <title>Functions in JavaScript.</title>
      <dc:creator>kamaldeen olaide, LAWAL.</dc:creator>
      <pubDate>Thu, 21 Jul 2022 17:54:00 +0000</pubDate>
      <link>https://dev.to/kamaldeenlawal/functions-in-javascript-4hji</link>
      <guid>https://dev.to/kamaldeenlawal/functions-in-javascript-4hji</guid>
      <description>&lt;ul&gt;
&lt;li&gt;
There are many core building blocks in programming language JavaScript included, and one the fundamental of any programming language is a function.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Function can simply be defined as code on demand or a block of code, which can be executed at a later point of time or called anywhere in your code to perform a specific task.&lt;/p&gt;

&lt;h1&gt;
  
  
  &lt;strong&gt;How to create functions&lt;/strong&gt;
&lt;/h1&gt;

&lt;h2&gt;
  
  
  ** Function Declaration**
&lt;/h2&gt;

&lt;p&gt;A function declaration (also known as a function statement, or function definition) must have the following:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Function keyword  (must).&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Any name of your choice, which serves as the name of the function.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;A parameter or list of parameters enclosed in parentheses (not a must).&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The function body is between curly brackets, which is the code you want to execute.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The code below shows a function named upscale.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Bk9IFzFE--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/lolujxibtbq0hvjm0wry.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Bk9IFzFE--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/lolujxibtbq0hvjm0wry.png" alt="function " width="800" height="351"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The above function has the function keyword, the body of the function (code inside the curly brackets), but doesn’t have a parameter.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Function expressions&lt;/strong&gt;
&lt;/h2&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; Function expression syntax is almost the same as that of a function declaration/statement, but in this case, the function is defined inside an expression with the function keyword at the right side of an assignment operator.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--unxHe3lk--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/u2qpy590djxoj0rkucp8.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--unxHe3lk--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/u2qpy590djxoj0rkucp8.png" alt="expression" width="800" height="382"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt; &lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Anonymous Function&lt;/strong&gt;
&lt;/h2&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;An anonymous function is the same as a function expression without a function name. An anonymous function can be used where you don’t store them in variables. An example is when it is used in an addEventListener method.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--MSMrh7R7--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/gwchux4s08ckoe3uh0do.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--MSMrh7R7--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/gwchux4s08ckoe3uh0do.png" alt="Annonymous" width="800" height="340"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Arrow function&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;The arrow function is a newly added feature to JavaScript to shorten and make our code neater. In this form of writing a function, the keyword "function" that is a must in all of the above ways of defining a function is not needed. Instead, we make use of an arrow symbol. It is always used on the right side of the equal sign and in place of the anonymous function. A sample is shown in the code below.&lt;/p&gt;

&lt;p&gt;The above code can be re-written in a shorter way if there is no argument, as shown below.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--XJW1JQTj--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/07ganmah725uinra0bs8.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--XJW1JQTj--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/07ganmah725uinra0bs8.png" alt="Arrow" width="726" height="444"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Note: An empty pair of parentheses is required.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--TWwpmX_J--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/cll1qj30wmss1v9m0fev.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--TWwpmX_J--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/cll1qj30wmss1v9m0fev.png" alt="Arrow 2" width="604" height="406"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Parentheses can be removed outright if there is only one parameter/argument, and if there is a single expression in the code, it can be written as shown below, where curly brackets can be omitted.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--M0v4aUe1--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/l2zlw21szw77cfjg0lzv.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--M0v4aUe1--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/l2zlw21szw77cfjg0lzv.png" alt="arrow 3" width="800" height="300"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Calling the defined functions&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;JavaScript will store the above code in memory because the code doesn’t run immediately when the script is loaded until you execute it by calling the function.&lt;/p&gt;

&lt;p&gt;A function is called using the name of the function with parentheses, and can be called as often as you like and wherever you want it to be called in your code.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--4UJJQt72--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ciqi2hgapaevnihx6dsh.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--4UJJQt72--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ciqi2hgapaevnihx6dsh.png" alt="define" width="448" height="330"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Function Hoisting&lt;/strong&gt;
&lt;/h2&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;For function declarations and statements, the code is automatically hoisted to the top and fully initialized by JavaScript, which means a function statement can be called before declaring it.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;While the code is hoisted to the top in function expressions, it is, however, hoisted as undefined as you can’t call a function expression without defining it.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;The difference between functions and methods&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Functions are reusable code that can be called anywhere in your code to execute a specific task. A method is also a function, but a function associated with an object or data type (String). They are defined on an object or a data type (String), whereas a function is defined on its own.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Rest Parameters&lt;/strong&gt;
&lt;/h2&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;The rest parameters/operator look like the spread operator. You add three dots "..." but the place you use the operator is different from the spread operator. In rest operator, the three dots are used in the function parameter list to perform the task of taking all the arguments the function gets and merging them all into an array, which enables you to call the function without passing an array.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--GMTHSSnS--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/1fszb1qhymcm3af47my1.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--GMTHSSnS--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/1fszb1qhymcm3af47my1.png" alt="rest" width="800" height="525"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;One important note about rest parameters is that there must not be more than one rest parameter and they must be the last arguments on the list.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Functions inside of functions&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;It is quite possible to have functions inside of functions, with the exception that the function inside will have a local scope to the functions. This kind of function is also known as a nested function.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--xx1TRoV2--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/fqnym30twl7c39v6eh9m.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--xx1TRoV2--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/fqnym30twl7c39v6eh9m.png" alt="nested" width="696" height="596"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If you noticed from the above code, the nested function is inside of an object. Don’t be surprised, the function is also an object.&lt;/p&gt;

&lt;h2&gt;
  
  
  **Parameters and arguments
&lt;/h2&gt;

&lt;p&gt;**&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;It is not suicidal for a programmer to use the words "parameter" and "argument" interchangeably, but there is a slight difference between the two.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Parameters are those variables used while defining a function within the parentheses.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--pJebkxPi--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/pnut6db9ab3ddbqprzte.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--pJebkxPi--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/pnut6db9ab3ddbqprzte.png" alt="parameter" width="634" height="406"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Arguments, on the other hand, are the concrete values you pass to a function when calling it.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--6TZJoAsl--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4qnlz7oek5q9is4gemh4.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--6TZJoAsl--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4qnlz7oek5q9is4gemh4.png" alt="arguments" width="696" height="330"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt; &lt;/p&gt;

&lt;p&gt; &lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Understanding callback functions&lt;/strong&gt;
&lt;/h2&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Callback functions are functions called for you by something else that can’t be controlled. This can be achieved with either an anonymous function or by storing it in a constant and passing the pointer to the function.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--1gXZvSNb--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/0my0c1vrmtnvclrbucnv.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--1gXZvSNb--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/0my0c1vrmtnvclrbucnv.png" alt="callback" width="800" height="467"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In the above code shown, we are passing a pointer to a function to another function, which makes it a value for a parameter of the addEventListener function.&lt;/p&gt;

&lt;p&gt;I hope you will learn one or two tips from this article.&lt;/p&gt;

&lt;p&gt;Enjoy.&lt;/p&gt;

&lt;p&gt; &lt;/p&gt;

&lt;p&gt; &lt;/p&gt;

</description>
      <category>javascript</category>
      <category>webdev</category>
      <category>beginners</category>
      <category>programming</category>
    </item>
    <item>
      <title>CSS Grid? the Nitty gritty?</title>
      <dc:creator>kamaldeen olaide, LAWAL.</dc:creator>
      <pubDate>Tue, 25 Jan 2022 08:54:14 +0000</pubDate>
      <link>https://dev.to/kamaldeenlawal/do-you-know-css-grid-5go</link>
      <guid>https://dev.to/kamaldeenlawal/do-you-know-css-grid-5go</guid>
      <description>&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;      **INTRODUCTION TO CSS GRID**
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;CSS grid is a two dimensional layout style that afford us the ability to create grid and place them on a webpage, it also give to us the ability to insert an element inside the grid and place the element as we wish. It has a two directions with columns coming down and rows going across.&lt;br&gt;
The easiest way to make a complex web design with different columns and multiple row is the css flex grid. It is superior to css flexbox but both can be used on same web design project.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;        **Grid Container**
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;The first thing is to take a div or an element and display grid, by displaying grid that open the ability to use grid on the div or the element.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--XsxJHjaH--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/adpe0kqx319s0vnapw8n.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--XsxJHjaH--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/adpe0kqx319s0vnapw8n.png" alt="GRID CONTAINER" width="800" height="498"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;         **Display Grid **
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;To make the above markup a grid, you add display grid to the div with class of container, this won’t change the layout of the element on the webpage.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--ig9GQFRp--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/v340zu9g8fpl13qss4z1.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--ig9GQFRp--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/v340zu9g8fpl13qss4z1.png" alt="Display grid" width="590" height="444"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;     **Grid-Template-Columns**
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;To specify the number of columns needed inside a grid is very easy to achieve; you can decide to have one, two, three or four column.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--pNW6KkXp--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/maxup1m7l3kklhchrcbi.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--pNW6KkXp--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/maxup1m7l3kklhchrcbi.png" alt="grid-template-column" width="800" height="351"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Bdnuu34g--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/fcb7wpk0iaxrygf7y8p3.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Bdnuu34g--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/fcb7wpk0iaxrygf7y8p3.png" alt="grid-template-column result" width="800" height="155"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The above code shows that the container has 4 column grid of 200px each; we can as well make each column a different width.&lt;br&gt;
To make the code in above snippet to look more enticing as we have repeated the use of 200px 4 times, we can set our grid-template-columns to the code below using a repeat function.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--HQoxrPfq--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ctdtu3qjm22czhhbsnfr.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--HQoxrPfq--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ctdtu3qjm22czhhbsnfr.png" alt="grid-template-column 1" width="800" height="389"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The first parameter inside the repeat function defines the number of repetition, while the second represent what to repeat; but to design your website to be responsive which is a core part of designing, instead of specifying the column in pixel or in percentage, there is a responsive unit in css grid which is fr.&lt;br&gt;
The fractional unit calculates the available space in the grid container.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Py9HTZSV--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/xq854p5gqqfqew1vlacv.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Py9HTZSV--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/xq854p5gqqfqew1vlacv.png" alt="grid-template-column 2" width="800" height="396"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Wp6mGQkE--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/0eovugeoux3gngzr001s.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Wp6mGQkE--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/0eovugeoux3gngzr001s.png" alt="grid-template-column result" width="800" height="83"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;As you can see from the result, the first, third and fourth column has 1fr has value, while 2fr was set as value for the second column; we can as well use the repeat function on the fr unit.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;      **Grid-Template-Rows**
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Similar to grid-template-columns, we have grid-template-rows which is primarily used to define the height and the number of rows in our grid container.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--EBPc_eMH--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/altvg8gb9cp6g4qoj26q.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--EBPc_eMH--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/altvg8gb9cp6g4qoj26q.png" alt="grid-template-rows result" width="800" height="56"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;           **Grid-Auto-Rows**
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;The grid property, grid-auto-rows affects rows when the size is not set initially.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--g8f3tPtX--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/bdtapsx8c4cp4cuwgdk3.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--g8f3tPtX--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/bdtapsx8c4cp4cuwgdk3.png" alt="grid auto rows" width="800" height="438"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--9_DIw5N1--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/jdu42h6khztsu36m9wbb.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--9_DIw5N1--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/jdu42h6khztsu36m9wbb.png" alt="grid-auto-rows 1" width="800" height="361"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Like I said earlier, the grid-auto-rows will only affects the grid container if the row was not initially set, but it won’t have any effect if the row is set.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--yAtsjM2N--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/jeeu4h5brpvoy8b18dva.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--yAtsjM2N--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/jeeu4h5brpvoy8b18dva.png" alt="grid-auto-rows 2" width="800" height="69"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;setting the grid-auto-rows as above means content inside the element is prone to overflow because we have set the fixed height; to prevent this occurrence, there is a feature that is known as minmax().&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;                **Minmax().**
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;The minmax function embedded in css grid enable us to set the value of both our columns and rows as we desired. This function as you can deduce from its name takes two values the minimum and the maximum values.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--YbPPjjLB--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/i8ecjn705kr7or4uaxy3.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--YbPPjjLB--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/i8ecjn705kr7or4uaxy3.png" alt="minmax function" width="800" height="385"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The above code shows that the grid-template -rows was set with minmax() that set its minimum row value to 100px and set the maximum value auto.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--aHZiD79c--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6nsvu4dn3y729hjw2kf4.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--aHZiD79c--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6nsvu4dn3y729hjw2kf4.png" alt="minmax function result" width="800" height="433"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;                    ** Gap.**
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;We can add gap or space between our column and rows in css grid using gap.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--TLA2EPQD--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/jm6stl428269hvfbdxyc.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--TLA2EPQD--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/jm6stl428269hvfbdxyc.png" alt="gap" width="800" height="459"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;With gap property set to 10px, both the column and the rows will have a spacing of 10px.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--XE9PTvuQ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/l8nte4rd2da40vkhdhb4.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--XE9PTvuQ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/l8nte4rd2da40vkhdhb4.png" alt="gap result" width="800" height="433"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;With css grid, it is possible to change the position of an items to any rows or columns as you deem fit; this to me is why grid outperform flexbox as you can literally change your layout as you wish.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;          ** Grid-column**
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Grid-column is used to span the item along the column axis; with this property, you can conveniently place your items anywhere you want in the grid.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--WyA0J0tU--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/f3xeyknnvscet6l3yx8a.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--WyA0J0tU--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/f3xeyknnvscet6l3yx8a.png" alt="grid-column" width="758" height="444"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;As you can see from the above code, the grid-column property set to .b0x-1 was set to start from line 1 and end at line 7 of the 6 column grid.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--p1NYCRmF--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/jadihvwikycjz9uvs1rz.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--p1NYCRmF--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/jadihvwikycjz9uvs1rz.png" alt="grid column result" width="800" height="100"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;             **Grid-rows**
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;This property is similar to grid-column, but instead of working on columns, the grid property grid-row works on rows.&lt;br&gt;
It is used to place the items in any rows within the layout.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--E28jFzKC--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/7r2ta45vbag0i315odib.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--E28jFzKC--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/7r2ta45vbag0i315odib.png" alt="grid row" width="758" height="482"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The code above will place the .box-1 to start at row 1 and end at line 4.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;       ** Grid-Templates-Areas**
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;This is one of the most interesting property in css grid, with this property you can literally configure and reconfigure your layout by giving specific names to the area on your grid.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--8L5Awsvw--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/cyxmece7k5ljqni7m09p.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--8L5Awsvw--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/cyxmece7k5ljqni7m09p.png" alt="grid-template-areas" width="800" height="616"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--sPcFxqU---/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/3qkopvscdxqgvclcdutx.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--sPcFxqU---/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/3qkopvscdxqgvclcdutx.png" alt="grid-template-areas result" width="800" height="433"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The above results shows that grid-template-areas was set on the grid container, with each row defined by an apostrophe (‘ ’) or quotation mark (“ “).&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;           **Grid-Area**
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Based on the above code, after the grid-template-areas has been set, the next step is to procced to the grid item in this case than main, section, aside and footer tags and set the grid area as appropriate.&lt;br&gt;
See below for the code that produced above result.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--8p_tNvuR--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/0aulxqfhavl8krgxyv1v.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--8p_tNvuR--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/0aulxqfhavl8krgxyv1v.png" alt="grid area" width="774" height="862"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;         **Justify-items**
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;This is use to align items in a grid along the row axis; the justify-items has a default value of stretch, but it does have three other values like start, end and center.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;           **align-items**
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Similar to justify-items but, it is use to align items in a grid along the column axis; the justify-items has a default value of stretch, but it does have three other values like start, end and center.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;        **Justify-content**
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Justify-content is used mainly when the grid size is smaller than the grid container, hence the property will be used to place grid content on row axis.&lt;br&gt;
This property has a default value of start, but it has stretch, center, end, space-around, space-between, and space-evenly.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;         **align-content**
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Just like justify-content, align-content is used mainly when the grid container has a fixed height, hence the property will be used to place grid content on column axis.&lt;br&gt;
This property has a default value of stretch, but it has start, center, end, space-around, space-between, and space-evenly.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;         **align-self**
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Align-self is used on the grid children itself, as it used to align the items along the column axis.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;       **justify-self**
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Justify-self is used on the grid children itself, as it used to align the items along the row axis.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--vhI4Ix9U--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/aubh8nu2qkhg2wih6lwc.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--vhI4Ix9U--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/aubh8nu2qkhg2wih6lwc.jpg" alt="illustrations" width="800" height="925"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;     **Conclussion**
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;This is a quick round down of the popular css grid, and i hope you will find this article helpful.&lt;/p&gt;

</description>
      <category>css</category>
      <category>javascript</category>
      <category>writing</category>
      <category>grid</category>
    </item>
    <item>
      <title>Quick Introduction to CSS Flexbox.</title>
      <dc:creator>kamaldeen olaide, LAWAL.</dc:creator>
      <pubDate>Thu, 20 Jan 2022 22:17:00 +0000</pubDate>
      <link>https://dev.to/kamaldeenlawal/quick-introduction-to-css-flexbox-4nc6</link>
      <guid>https://dev.to/kamaldeenlawal/quick-introduction-to-css-flexbox-4nc6</guid>
      <description>&lt;p&gt;This is a quick introduction to one of the most popular CSS concepts; which is CSS flexBox.&lt;br&gt;
    In this short write-up, I will introduce you to this popular CSS concepts.&lt;br&gt;
    &lt;strong&gt;What is Flexbox?&lt;/strong&gt;&lt;br&gt;
  This is a one dimensional layout model that make it easy to design efficient and flexible layout, control page alignment, and distribute spaces among items.&lt;br&gt;
   Before the advent of flexbox, there are many methods to layout model in web development which includes;&lt;br&gt;
• Block&lt;br&gt;
• Table (For two-dimensional table data).&lt;br&gt;
• Inline (Explicitly for test)&lt;br&gt;
• Positioning&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;WHY FLEXBOX&lt;/strong&gt;? With flexbox, items can be arranged as you want with enough flexibility, and it is one of the core concepts for front-end web developer.&lt;/p&gt;

&lt;p&gt;To get a proper grasp of flexbox and how it works, we have to understand its core concepts.&lt;br&gt;
 Main axis (Left to right)&lt;br&gt;
 Cross axis (Perpendicular to Main axis, i.e from &lt;br&gt;
   top to bottom)&lt;br&gt;
 Parent Container (Flex Container)&lt;br&gt;
 Children Element (Flex Item)&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Main Axis&lt;/strong&gt;: Main axis flows from left to right by default, while main end is at the right, main start is the left of the main axis.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Cross Axis&lt;/strong&gt;: Cross axis flows from top to down by default, while cross start is at the top, cross end is the bottom of the cross axis.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Parent Container&lt;/strong&gt; (Flex Container):  this container accepts various properties that are listed below.&lt;br&gt;
 Display&lt;br&gt;
 Flex-Direction&lt;br&gt;
 Flex-Wrap&lt;br&gt;
 Flex-Flow&lt;br&gt;
 Justify-content&lt;br&gt;
 Align-items&lt;br&gt;
 Align-contents&lt;br&gt;
  Let us start by analyzing the above listed properties one after the other and knows the actual work they are meant for.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Display&lt;/strong&gt;: You will recall, display is one of flexbox container properties, let me share a snippet of code before and after I added a display property to the code. &lt;/p&gt;

&lt;p&gt;Before adding the display property&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--FxMo8ur1--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/jiffcsn1jy08l7zwanzn.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--FxMo8ur1--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/jiffcsn1jy08l7zwanzn.png" alt="Image description" width="800" height="430"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This is the result gotten from my the code below;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--CSXtBCZM--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/hlgpqu5drzpwyy7p8jc1.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--CSXtBCZM--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/hlgpqu5drzpwyy7p8jc1.png" alt="Image description" width="800" height="477"&gt;&lt;/a&gt;&lt;br&gt;
  Notice the code above? We have a div with a container class; that div serve as the parent container, while the remaining nine div are the child elements, as rightly explained above.&lt;br&gt;
In my CSS file (file not shared here), I added a border to the parent container, I gave the child-item element padding and align the text to center, while each of the boxes were given a unique background color.&lt;/p&gt;

&lt;p&gt;After adding the display property.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--WxUeYjOz--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/217vid948bze200cs7we.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--WxUeYjOz--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/217vid948bze200cs7we.png" alt="Image description" width="800" height="431"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The code that did the trick above is below.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--4Mvj-OUG--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/w1p6j04lglw0lvshfh1g.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--4Mvj-OUG--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/w1p6j04lglw0lvshfh1g.png" alt="Image description" width="800" height="431"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;What you need to do is simple and straightforward, locate your class of container in your CSS code, and input this DISPLAY:FLEX;.&lt;br&gt;
NOTE:  There is an inline-flex property as well, but rarely use.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Flex-Direction:&lt;/strong&gt;  This is an important property of the flex container as it establishes the main axis, which in turn decides how the flex-items are placed inside the flex container.&lt;br&gt;
The default setting of the main axis is to flow from left to right, but we can however change how the flex-items are placed in the flex container by changing the direction of the flex-direction.&lt;/p&gt;

&lt;p&gt;Let us go back to our CSS file to make the effect on our layout, the flex-direction can accept four value to change the direction of the flex-items, they are as follows.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;           _Flex-Direction: row;_
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--NrtdnaSq--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/lbxcanticnj2e209wogq.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--NrtdnaSq--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/lbxcanticnj2e209wogq.png" alt="Image description" width="800" height="431"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;By setting the flex-direction to row; the layout won’t be changed, as row is the default value for the flex-direction.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;      _Flex-Direction: row-reverse;_
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;With this selection, our layout will change from the initial setup, it will change the flex-items in the reverse order, see snippet for proper understanding.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Ctnl07Ij--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6nlsu34cydbcctm7q843.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Ctnl07Ij--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6nlsu34cydbcctm7q843.png" alt="Image description" width="800" height="351"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;         The code
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--ZpTmnaDk--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/yj6gfqw9imfy6yofxznd.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--ZpTmnaDk--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/yj6gfqw9imfy6yofxznd.png" alt="Image description" width="800" height="431"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;         _Flex-Direction: column:_
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;With flex-direction set to column, the direction of the main axis changes from top to bottom, which means the items are now stacked on each other. See code and result for more.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--ki94zn2V--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/cg8t73uxch0hutz1f7t2.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--ki94zn2V--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/cg8t73uxch0hutz1f7t2.png" alt="Image description" width="800" height="431"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--kQynrFGD--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/v8vmd6k56tgdmyp8w74x.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--kQynrFGD--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/v8vmd6k56tgdmyp8w74x.png" alt="Image description" width="800" height="453"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;     _Flex-Direction: column-reverse:_
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;This property set the direction of the main-axis from top to bottom in the reverse direction.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--MA4lTBQQ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/bwo3z70i8koubsir3gpb.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--MA4lTBQQ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/bwo3z70i8koubsir3gpb.png" alt="Image description" width="800" height="431"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--jDFeoCkV--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/sjfdvbfspns7jy5wipka.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--jDFeoCkV--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/sjfdvbfspns7jy5wipka.png" alt="Image description" width="800" height="559"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Flex-Wrap&lt;/strong&gt;: Another important property of the parent container is the flex-wrap property. By default, all the flex-items in a container will try to fit into a single line, and where there is limited space, the flex-items will overflow to another line. With flex-rap, three distinct property can be set on the flex-warp property.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;        _Flex-Wrap: nowrap:_
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Nowrap is the default value of flex-warp, and it will display as the initial layout, snippet of code for more illustration.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--JmIHtUGg--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/y20ex8gubb0eazh0uxcq.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--JmIHtUGg--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/y20ex8gubb0eazh0uxcq.png" alt="Image description" width="800" height="431"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;           _Flex-Wrap: wrap:_
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;With the value of the flex-wrap set to wrap, the flex-items will be wrapped within the flex container. See code for more illustration.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--os12bwFA--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/n9wka2k1faokm2196z9n.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--os12bwFA--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/n9wka2k1faokm2196z9n.png" alt="Image description" width="800" height="431"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--TAO16DdX--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/svmp50fqt67zem492y56.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--TAO16DdX--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/svmp50fqt67zem492y56.png" alt="Image description" width="800" height="600"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Wrapping takes place as at when needed, as you can see, as there is not enough space for box 7 and box 8 they moved down to row below.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;      _Flex-Wrap: wrap-reverse:_
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;The main distinct between wrap-reverse and wrap is instead of the item's to move to row below as in the case of war, it in turn moves to row above because of the wrap reverse, see code snippet and output for illustration.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--SPGSj3JD--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/cb0rmxyjdc5wljgpcebe.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--SPGSj3JD--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/cb0rmxyjdc5wljgpcebe.png" alt="Image description" width="800" height="431"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Mudt3uHH--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/f5yx2wn5m92lvs1rlfw4.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Mudt3uHH--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/f5yx2wn5m92lvs1rlfw4.png" alt="Image description" width="628" height="190"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Flex-Flow:&lt;/strong&gt; Another property of the parent container is the flex-flow property. It is straightforward, as it is the shorthand for flex-direction and flex-wrap.&lt;br&gt;
 Flex-flow is set to flex-direction = row and flex-wrap = nowrap by default because that is the default value for flex-direction and flex-wrap property.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Z9bBPXx7--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/kp76x1zbro0yu13og27s.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Z9bBPXx7--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/kp76x1zbro0yu13og27s.png" alt="Image description" width="800" height="431"&gt;&lt;/a&gt;&lt;br&gt;
  While setting the values for flex-flow property, be minded that the first values is for the flex-direction while the second value is for the flex-flow property.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--0n1cZJoc--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/oapk6xcmpmxrbd6zr4a1.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--0n1cZJoc--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/oapk6xcmpmxrbd6zr4a1.png" alt="Image description" width="800" height="431"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;We can set all values for flex-direction (row, column, column-reverse and row-reverse) and values for flex-wrap (wrap, nowrap, wrap-reverse) on flex-flow.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Justify-Content&lt;/strong&gt;: This is an alignment property provided by flexbox on flex container; Justify-content defines the alignment along the main axis, recalled that main axis flows from left to right.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;  _ Justify-content: flex-start:_
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--7x5wRYKy--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/yznbpl0eyxvkmeeynwpz.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--7x5wRYKy--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/yznbpl0eyxvkmeeynwpz.png" alt="Image description" width="800" height="431"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--uD-SEewJ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/zv8teald9qoivysbctdp.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--uD-SEewJ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/zv8teald9qoivysbctdp.png" alt="Image description" width="478" height="82"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The above is the code and result when the justify-content value is set to start. Here the items will be aligned to the left which is the start of the main axis.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    __Justify-content: flex-end:_
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;As the name implies, setting justify-content value to end will align the items to the right of the main axis which is the end of the main axis.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--NdVoOGz2--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/upd5e32sc0h7aflw6ubc.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--NdVoOGz2--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/upd5e32sc0h7aflw6ubc.png" alt="Image description" width="800" height="431"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--s5Hy60SF--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ge6cn1wb8f7vnix5fqbe.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--s5Hy60SF--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ge6cn1wb8f7vnix5fqbe.png" alt="Image description" width="580" height="82"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;     _Justify-content: center:_
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;By setting the value for the justify-content to center, you have aligned the items in the flex container to be at the center of the main axis.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--lw7OwBOi--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/mtw8y1xjbzphhdh6b17s.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--lw7OwBOi--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/mtw8y1xjbzphhdh6b17s.png" alt="Image description" width="590" height="89"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--EwfCUZpO--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/aeiwltauua3tt8fu9iek.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--EwfCUZpO--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/aeiwltauua3tt8fu9iek.png" alt="Image description" width="800" height="431"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    _Justify-content: space-between:_
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;With space between, the extra spaces between the items are evenly split and added in between the flex items.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--zl4K0OpF--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/fwifvrbj7xhci3mr1chj.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--zl4K0OpF--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/fwifvrbj7xhci3mr1chj.png" alt="Image description" width="800" height="431"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    _Justify-content: space-around:_
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;You might desire that there should be spaces at both beginning and end of your item, the value to set your justify-content to be space around, but note the spaces between the flex items is twice more than the space at the start and end of the items.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--p3KId6DZ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/x8lpjr1g4dq18bge39x9.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--p3KId6DZ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/x8lpjr1g4dq18bge39x9.png" alt="Image description" width="800" height="431"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--TFTL75f2--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/km2xcg920mu4li4ncwva.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--TFTL75f2--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/km2xcg920mu4li4ncwva.png" alt="Image description" width="595" height="79"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;      _Justify-content: space-evenly:_
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;To get the remaining spaces evenly distributed in the container, set the value of the justify-content to space evenly.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--x1GzFBgZ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/lym06aves3nus51qjmkq.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--x1GzFBgZ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/lym06aves3nus51qjmkq.png" alt="Image description" width="800" height="431"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--RZma7DNR--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/asnkzszisivxxd23hn8v.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--RZma7DNR--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/asnkzszisivxxd23hn8v.png" alt="Image description" width="595" height="86"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;One important point you should keep in mind while working with justify content is that, it align the items based on the main axis. It works directly with the direction set by flex-direction.&lt;br&gt;
 If the flex-direction is set to column, then, the justify-content will deal with vertical alignment.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--iePgX2_o--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ssx0sg9ky10jjkffsbqn.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--iePgX2_o--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ssx0sg9ky10jjkffsbqn.png" alt="Image description" width="800" height="431"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--oZ6sGSOr--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/qhcao3r5gx53vmcg218k.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--oZ6sGSOr--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/qhcao3r5gx53vmcg218k.png" alt="Image description" width="628" height="707"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Align-items&lt;/strong&gt;: This is an alignment property provided by flexbox on flex container; Align-items defines the default behavior of how flex items are laid out along the cross axis of the container.&lt;br&gt;
  It works like justify-content but in the perpendicular direction.&lt;br&gt;
               &lt;em&gt;Align-Item: Stretch:&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--TjyQJgp9--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/pf0dhlao2vr00q89v41c.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--TjyQJgp9--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/pf0dhlao2vr00q89v41c.png" alt="Image description" width="758" height="558"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--wNOsqg8w--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4xmobqpjtm16t6kdqa9u.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--wNOsqg8w--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4xmobqpjtm16t6kdqa9u.png" alt="Image description" width="480" height="325"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Above is the snippet of cod and result when the align-items value is set to stretch.&lt;br&gt;
This is also the default value of the align-items property.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;       _Align-Item: Flex-Start:_
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--XgQ8NeLu--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/8r8j11vyk9x33tw7lpth.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--XgQ8NeLu--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/8r8j11vyk9x33tw7lpth.png" alt="Image description" width="760" height="482"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--r_Eceynu--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/a0kgq879v7fluo9hww3c.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--r_Eceynu--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/a0kgq879v7fluo9hww3c.png" alt="Image description" width="480" height="112"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;All the items are pushed to the cross start, we should remember that cross axis flow from top to bottom.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    _ Align-Item: Flex-End:_
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--pJ3pJimH--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/v74f7zg7ahp10sylhz1j.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--pJ3pJimH--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/v74f7zg7ahp10sylhz1j.png" alt="Image description" width="760" height="520"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--7QVuFDYA--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/bunp7ntk9ryzw1lejg1y.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--7QVuFDYA--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/bunp7ntk9ryzw1lejg1y.png" alt="Image description" width="484" height="273"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In the above code, all items are pushed to the cross end. &lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;        _Align-Item: Center:_
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--fHLnmK9E--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/axh7sy23emr1cj0dsajc.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--fHLnmK9E--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/axh7sy23emr1cj0dsajc.png" alt="Image description" width="758" height="520"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The code above centered along the cross axis.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Children Elements (Flex Items)&lt;/strong&gt;:  this container accept various properties that are listed below.&lt;br&gt;
 Order&lt;br&gt;
 Flex-grow&lt;br&gt;
 Flex-Shrink&lt;br&gt;
 Flex-Basis&lt;br&gt;
 Flex&lt;br&gt;
 Align-self&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Order&lt;/em&gt;: The items in a flex container are laid out in the order in which they appear in the source code. We can only change this order in flex by using the order property.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--pVwYVKja--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/tqy27kdv8tf3qq8ibl93.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--pVwYVKja--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/tqy27kdv8tf3qq8ibl93.png" alt="Image description" width="758" height="444"&gt;&lt;/a&gt;&lt;br&gt;
By giving the items an order higher than 0, the item will be pushed all the way to the end; this is because by default all items have a default order of 0.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Flex-Grow&lt;/em&gt;: The next property that can be applied on a flex items is the flex grow property; this property specifies the amount of spaces inside the flex container the item should take up.&lt;br&gt;
The flex-grow property is relative to the size of other items in the container.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--4JDQZYB_--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ruyqrih2t2qml46qlxy8.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--4JDQZYB_--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ruyqrih2t2qml46qlxy8.png" alt="Image description" width="742" height="444"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--w7nPB6RP--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/crs122qxgp0dj5glqd0q.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--w7nPB6RP--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/crs122qxgp0dj5glqd0q.png" alt="Image description" width="800" height="55"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Flex-grow default value is 0 and if you want to effect change, you will set values greater than 0.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Flex-Shrink&lt;/em&gt;: This property specifies the amount of spaces inside the flex container the item should shrink if necessary, but unlike flex-grow, the default value for flex-shrink is 1.&lt;br&gt;
The flex-shrink property is relative to the size of other items in the container.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--8M6qph39--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/f4r08wwzyjnzbq71qgt6.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--8M6qph39--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/f4r08wwzyjnzbq71qgt6.png" alt="Image description" width="760" height="444"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Flex-Basis&lt;/em&gt;: The next property is the flex-basis, which specifies the initial space of a flex item, before the distribution of extra spaces in the container. This is used in place of with ion flex layout.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Lua41j4T--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/x9vu1s7k8r6lxl01qic9.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Lua41j4T--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/x9vu1s7k8r6lxl01qic9.png" alt="Image description" width="760" height="444"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--0-2TiQa9--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/2hypw0x84esq6k554i2h.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--0-2TiQa9--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/2hypw0x84esq6k554i2h.png" alt="Image description" width="800" height="45"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Flex&lt;/em&gt;:  Flex is the short hand for flex-grow/flex-shrink and flex-basis.&lt;br&gt;
Although, we can set the value individually, but the recommended way is to use the flex property. &lt;br&gt;
We can set the values like code below i.e three values separated by space.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--sbXirfES--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/30z3z2oyj5i7fmganqe8.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--sbXirfES--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/30z3z2oyj5i7fmganqe8.png" alt="Image description" width="760" height="444"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The first value represent the flex-grow, second value represent the flex-shrink while the third value represent the flex-basis.&lt;br&gt;
N.B the default value for flex-grow, flex-shrink is 0 and 1 respectively.&lt;/p&gt;

&lt;p&gt;Align-Self: Align-self is used to control the alignment of the individual flex-items along the cross sectional axis.&lt;/p&gt;

&lt;p&gt;**  I hope with this short but precise write-up about the popular css flexbox you will be able to understand it well.&lt;br&gt;
Thanks for your time.**&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>css</category>
      <category>beginners</category>
      <category>tutorial</category>
    </item>
  </channel>
</rss>
