<?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: Ambush3</title>
    <description>The latest articles on DEV Community by Ambush3 (@ambush3).</description>
    <link>https://dev.to/ambush3</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%2F606246%2Fd08cac00-0966-4a21-afe8-37d0c97d4294.jpeg</url>
      <title>DEV Community: Ambush3</title>
      <link>https://dev.to/ambush3</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/ambush3"/>
    <language>en</language>
    <item>
      <title>Things That Make TypeScript Great</title>
      <dc:creator>Ambush3</dc:creator>
      <pubDate>Thu, 27 Apr 2023 12:28:46 +0000</pubDate>
      <link>https://dev.to/ambush3/things-that-make-typescript-great-1op6</link>
      <guid>https://dev.to/ambush3/things-that-make-typescript-great-1op6</guid>
      <description>&lt;p&gt;TypeScript is a popular programming language developed by Microsoft that adds optional static typing and other features to JavaScript. It's becoming increasingly popular for its ability to catch common errors and improve code readability and maintainability. Here are some of the things I learned about TypeScript, and some things that make it a great tool to use:&lt;/p&gt;

&lt;h3&gt;
  
  
  TypeScript is a superset of JavaScript.
&lt;/h3&gt;

&lt;p&gt;One of the main benefits of TypeScript is that it's a superset of JavaScript, meaning that any valid JavaScript code is also valid TypeScript code. This makes it easy to get started with TypeScript if you already have experience with JavaScript.&lt;/p&gt;

&lt;h3&gt;
  
  
  TypeScript adds static typing.
&lt;/h3&gt;

&lt;p&gt;One of the key features of TypeScript is its support for static typing. By adding type annotations to your code, you can catch errors at compile time instead of at runtime. This can help you write more robust and maintainable code.&lt;/p&gt;

&lt;h3&gt;
  
  
  TypeScript has a powerful type system.
&lt;/h3&gt;

&lt;p&gt;TypeScript's type system is much more powerful than JavaScript's. It includes support for union types, intersection types, generics, and more. This can make it easier to write code that is both flexible and type-safe.&lt;/p&gt;

&lt;h3&gt;
  
  
  TypeScript can help you catch errors earlier.
&lt;/h3&gt;

&lt;p&gt;Because TypeScript is a statically typed language, it can catch errors earlier in the development process. This can save you time and effort by preventing errors from propagating throughout your codebase.&lt;/p&gt;

&lt;h3&gt;
  
  
  TypeScript can improve code readability and maintainability.
&lt;/h3&gt;

&lt;p&gt;By adding type annotations to your code, you can make it more clear and understandable. This can make it easier for other developers to work with your code and can improve its maintainability over time.&lt;/p&gt;

&lt;h3&gt;
  
  
  TypeScript integrates well with popular frameworks.
&lt;/h3&gt;

&lt;p&gt;TypeScript has good integration with popular frameworks like React, Angular, and Vue. This can make it easier to write type-safe code in these frameworks and take advantage of TypeScript's powerful features.&lt;/p&gt;

&lt;p&gt;Overall, TypeScript is a powerful programming language that can help you write more robust and maintainable code. By adding static typing and other features to JavaScript, it can catch errors earlier in the development process and improve code readability and maintainability. If you haven't already, it's definitely worth checking out TypeScript and seeing how it can help you improve your code.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Converting our Backbone.js Admin Dashboard to Vue, and how great it was.</title>
      <dc:creator>Ambush3</dc:creator>
      <pubDate>Mon, 20 Mar 2023 16:13:09 +0000</pubDate>
      <link>https://dev.to/ambush3/converting-our-backbonejs-admin-dashboard-to-vue-and-how-great-it-was-4b56</link>
      <guid>https://dev.to/ambush3/converting-our-backbonejs-admin-dashboard-to-vue-and-how-great-it-was-4b56</guid>
      <description>&lt;p&gt;As our web application grew in complexity, we recognized the importance of using modern and efficient frameworks to improve the user experience and overall performance. Vue.js, a progressive JavaScript framework that allows developers to build scalable and maintainable applications with ease, was gaining popularity at the time. In this blog post, we discussed the process of converting our Admin Dashboard Page from Backbone.js/JavaScript to Vue.js/Vuetify and the benefits that came with it.&lt;/p&gt;

&lt;p&gt;Backbone.js had been a popular framework for building single-page applications, but it had some limitations, especially when it came to scaling and performance. Vue.js provided a more flexible and modular approach to building web applications. By using Vue.js, I was able to easily break down our application into smaller components, making it easier to maintain and scale.&lt;/p&gt;

&lt;p&gt;The first step in converting the Admin Dashboard Page from Backbone.js to Vue.js was to understand the structure of our current application. I needed to identify the different components and functionalities of the page and create a plan for how we would migrate them to Vue.js. I made sure to have a solid understanding of Vue.js and its various components, such as templates, components, and directives.&lt;/p&gt;

&lt;p&gt;Once we had a plan in place, I started migrating our code. I began by adding Vue.js templates, which involved gradually replacing the Backbone.js views with Vue.js components. I also replaced the existing Backbone.js models and collections with Vue.js data objects, which I was able to do easily using Vue.js data properties.&lt;/p&gt;

&lt;p&gt;One of the biggest benefits I experienced from using Vue.js was its ability to create reusable components, which saved time and effort in the long run. With Vue.js, I was able to easily create custom components and reuse them throughout our application, significantly reducing our development time.&lt;/p&gt;

&lt;p&gt;Another benefit of Vue.js was its integration with Vuetify, a popular UI component library that provided us with a wide range of ready-to-use components. By using Vuetify, I was able to easily create a consistent and visually appealing interface for our Admin Dashboard Page, without the need for custom CSS.&lt;/p&gt;

&lt;p&gt;In conclusion, the conversion from Backbone.js to Vue.js/Vuetify brought significant benefits, such as improved scalability, maintainability, and performance. Though it took some effort and planning to make the switch, the long-term benefits made it well worth it. With Vue.js and Vuetify, I was able to create a more efficient and user-friendly application that benefited both our users and our development team.&lt;/p&gt;

</description>
      <category>vue</category>
      <category>backbonej</category>
      <category>javascript</category>
      <category>typescript</category>
    </item>
    <item>
      <title>MVC Architecture Explained</title>
      <dc:creator>Ambush3</dc:creator>
      <pubDate>Fri, 19 Aug 2022 01:13:00 +0000</pubDate>
      <link>https://dev.to/ambush3/mvc-architecture-explained-2d8d</link>
      <guid>https://dev.to/ambush3/mvc-architecture-explained-2d8d</guid>
      <description>&lt;h2&gt;
  
  
  What is MVC? What is its purpose?
&lt;/h2&gt;

&lt;p&gt;Created in 1979, applications started to become more complex and people wanted to find new ways of creating applications fast, organized, and easier. Through MVC, such things are possible.&lt;/p&gt;

&lt;p&gt;MVC is an architectural design pattern. &lt;br&gt;
Through separation of concerns, we can improve application organization by using MVC. MVC breaks down to three components: Model, View, and Controller.&lt;br&gt;
It doesn't belong to a specific programming language or framework. &lt;br&gt;
Instead, it's just an architecture that can be used to create any kind of application in all sorts of languages and frameworks. Such as Rails, Django, Laravel, AngularJS, and CakePHP, are just some of frameworks that use the MVC architecture.&lt;/p&gt;

&lt;p&gt;It's purpose is to separate the different aspects of the application. Input logic, business logic, and the GUI. &lt;br&gt;
The logic belongs in the model, the GUI belongs in the view, and input logic belongs in the controller. This separation helps with the comlexity when you build an application by enabling you to focus on just on aspect at a time. &lt;/p&gt;

&lt;h2&gt;
  
  
  Some of the benefits of MVC include:
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Fast&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Multiple developers can collaborate and work together&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Search Engine Optimization (SEO) friendly&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Reusability&lt;/strong&gt; - The same or similar view in your application maybe refactored for another application but with different data because the view is only handling how the data is being displayed.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Scalability&lt;/strong&gt; - You can actually upgrade the hardware running the DB without other components being affected.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Extendibility&lt;/strong&gt; - You can make changes to one, or fix bugs on one component, without messing up the other. &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Simultaneous Development&lt;/strong&gt; - Working parallel on different components without blocking or affecting one another.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Some of the disadvantages of MVC include:
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Complexity&lt;/strong&gt; - The framework navigation can be complex because it introduces new layers of abstraction.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Multiple technologies&lt;/strong&gt; - Through MVC a lot of frameworks and languages can be introduced, which can be a bit of a burden to some developers.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Lots of code to maintain inside of the controller&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Strict rules on the methods&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  The Design of MVC
&lt;/h2&gt;

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

&lt;p&gt;Like I stated before, MVC has three components called Model, View, and Controller.&lt;br&gt;
Each component plays an important role in the application development.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Model&lt;/strong&gt; is responsible for managing the data of the application. It receives user input from the controller.&lt;br&gt;
It adds and and retrieves items from the DB, processing data from or to the DB. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;View&lt;/strong&gt; means the presentation of the model in a certain format.&lt;br&gt;
It is the only thing the user ever sees. Most of the time it only speaks with the controller. There is no logic or database that you can see in the view. The view is solely for user interaction and everything behind the scenes is done in the Controller and the Model.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Controller&lt;/strong&gt; responds to the users input and performs interactions on the data model objects.&lt;br&gt;&lt;br&gt;
It processes the GET/POST/PUT/DELETE requests. It acts as a middle man to take information from the user, process the information, and talks to the DB if it needs to. The controller speaks to the view, and explains the presentation to the user(view). &lt;/p&gt;

</description>
      <category>javascript</category>
      <category>mvc</category>
      <category>frameworks</category>
      <category>programming</category>
    </item>
    <item>
      <title>New Features Introduced from ES2022</title>
      <dc:creator>Ambush3</dc:creator>
      <pubDate>Fri, 08 Jul 2022 13:29:35 +0000</pubDate>
      <link>https://dev.to/ambush3/new-features-introduced-from-es2022-375k</link>
      <guid>https://dev.to/ambush3/new-features-introduced-from-es2022-375k</guid>
      <description>&lt;p&gt;As JavaScript keeps involving every year with ECMAScript specifications being released every year since 2015. &lt;br&gt;
Here are a 4 new features coming from ES2022 that you may find useful.&lt;/p&gt;

&lt;h2&gt;
  
  
  1. Top Level Await
&lt;/h2&gt;

&lt;p&gt;The await keyword previously couldn’t be used outside the async box. Now we can use await without async. &lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Top-level await enables modules to act as big async functions: With top-level await, ECMAScript Modules (ESM) can await resources, causing other modules who import them to wait before they start evaluating their body.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;An example of this: &lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--9CwynOfE--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/1jo7bl7y1cidrl1etdx0.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--9CwynOfE--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/1jo7bl7y1cidrl1etdx0.png" alt="Image description" width="800" height="434"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  2. Error Cause
&lt;/h2&gt;

&lt;p&gt;Errors help us identify the unexpected behavior our applications may produce when things don't go the way they are planned, and help us react accordingly. &lt;br&gt;
Sometimes however, it is hard to determine the root cause of the nested errors, and how to handle them properly.&lt;/p&gt;

&lt;p&gt;But now, we can pass the object {cause: err} to the Error constructor to &lt;br&gt;
to show us what caused the error to happen: &lt;/p&gt;

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

&lt;h2&gt;
  
  
  3. &lt;strong&gt;RegExp&lt;/strong&gt; match indices with the &lt;strong&gt;d&lt;/strong&gt; flag
&lt;/h2&gt;

&lt;p&gt;Regular expression matches are patterns that are used to find certain character combinations in strings.&lt;br&gt;
Using &lt;strong&gt;String.matchAll&lt;/strong&gt; and &lt;strong&gt;RegExp.exec&lt;/strong&gt;, we can return a list of matches: &lt;/p&gt;

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

&lt;p&gt;&lt;strong&gt;RegExp.exec&lt;/strong&gt; will deliver individual results. &lt;strong&gt;String.matchAll&lt;/strong&gt; will return an iterator that can be used to iterate over all the matches. &lt;/p&gt;

&lt;p&gt;Thanks to ES2022, we can now use the &lt;strong&gt;d&lt;/strong&gt; flag to specify starting and ending indices of the matches in the &lt;strong&gt;RegExp&lt;/strong&gt; result:&lt;/p&gt;

&lt;h2&gt;
  
  
  4. &lt;strong&gt;.at()&lt;/strong&gt; method for arrays.
&lt;/h2&gt;

&lt;p&gt;Instead of slicing the array and getting its length until we get what we want. This feature will help you get what you want in a line of code. Perfect for readability and less code.&lt;/p&gt;

&lt;p&gt;It provides an easy access to any index of an array or string, either positive or negative: &lt;/p&gt;

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

</description>
      <category>javascript</category>
      <category>webdev</category>
      <category>programming</category>
      <category>news</category>
    </item>
    <item>
      <title>Working with JavaScript Arrays Pt. 3</title>
      <dc:creator>Ambush3</dc:creator>
      <pubDate>Sun, 05 Jun 2022 14:28:47 +0000</pubDate>
      <link>https://dev.to/ambush3/working-with-javascript-pt-3-46e</link>
      <guid>https://dev.to/ambush3/working-with-javascript-pt-3-46e</guid>
      <description>&lt;p&gt;Often in JavaScript you'll come across big long strings, that you'll more than likely want to separate certain items out into a more useful form, so then you can display them differently. Like a table for instance.&lt;/p&gt;

&lt;p&gt;To do such an action, we can use the method, &lt;strong&gt;&lt;em&gt;split()&lt;/em&gt;&lt;/strong&gt;.&lt;br&gt;
Split takes a single parameter, which is the character you want to separate the string at, puts these substrings into an array, then returns the array.&lt;br&gt;
Let's play around with it. &lt;/p&gt;

&lt;h2&gt;
  
  
  *&lt;em&gt;1. First we create a string. *&lt;/em&gt;
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--zXZmez5X--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn.hashnode.com/res/hashnode/image/upload/v1650719701338/EqYwkf1hH.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--zXZmez5X--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn.hashnode.com/res/hashnode/image/upload/v1650719701338/EqYwkf1hH.png" alt="image.png" width="800" height="264"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  *&lt;em&gt;2. Next, we'll split it at every comma. *&lt;/em&gt;
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--nvE-r5Qc--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn.hashnode.com/res/hashnode/image/upload/v1650719845192/9dIgLtUlG.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--nvE-r5Qc--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn.hashnode.com/res/hashnode/image/upload/v1650719845192/9dIgLtUlG.png" alt="image.png" width="800" height="336"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;3. Lastly, we can find the length of the new array, and receive some items from it.&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--p5zOvBPe--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn.hashnode.com/res/hashnode/image/upload/v1650720055915/VkfFrNpuq.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--p5zOvBPe--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn.hashnode.com/res/hashnode/image/upload/v1650720055915/VkfFrNpuq.png" alt="image.png" width="800" height="275"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  *&lt;em&gt;4. You can do the opposite of .split(), by using the .join() method. *&lt;/em&gt;
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--3jBcAU7O--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn.hashnode.com/res/hashnode/image/upload/v1650739090417/OoQlBUjaA.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--3jBcAU7O--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn.hashnode.com/res/hashnode/image/upload/v1650739090417/OoQlBUjaA.png" alt="image.png" width="800" height="281"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;5. One of the other ways of converting an array to a string, is using the ***.toString()&lt;/strong&gt;* method.
&lt;/h2&gt;

&lt;p&gt;The .toString() method is more simple than the &lt;strong&gt;&lt;em&gt;.join()&lt;/em&gt;&lt;/strong&gt; method. It doesn't take a parameter. But, it is more limiting to use.&lt;br&gt;
With the &lt;strong&gt;&lt;em&gt;.join()&lt;/em&gt;&lt;/strong&gt; method, you can specify different separators, whereas with &lt;strong&gt;&lt;em&gt;.toString()&lt;/em&gt;&lt;/strong&gt; method, it always uses a comma. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--OQyYWOng--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn.hashnode.com/res/hashnode/image/upload/v1650742064358/021KjTW3F.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--OQyYWOng--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn.hashnode.com/res/hashnode/image/upload/v1650742064358/021KjTW3F.png" alt="image.png" width="800" height="295"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>javascript</category>
      <category>beginners</category>
      <category>programming</category>
    </item>
    <item>
      <title>Working with JavaScript Arrays Pt. 2</title>
      <dc:creator>Ambush3</dc:creator>
      <pubDate>Sun, 05 Jun 2022 14:26:06 +0000</pubDate>
      <link>https://dev.to/ambush3/working-with-javascript-arrays-pt-2-3m71</link>
      <guid>https://dev.to/ambush3/working-with-javascript-arrays-pt-2-3m71</guid>
      <description>&lt;p&gt;In part 1 of JavaScript Arrays, we learned how to create arrays, finding the arrays length, and then accessing array items.&lt;/p&gt;

&lt;p&gt;In part 2, we'll look at finding items in the array, adding items, removing items, and accessing every item.&lt;/p&gt;

&lt;h3&gt;
  
  
  Finding Items in An Array
&lt;/h3&gt;

&lt;p&gt;With arrays you can find the index of a particular item, using the*** indexOf() ***method. This takes an item as an argument and returns the index location, or, if the item doesn't exist. It returns a -1.&lt;/p&gt;

&lt;p&gt;For instance: &lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--sflbiuef--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn.hashnode.com/res/hashnode/image/upload/v1649005334768/gX_bLVyl4.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--sflbiuef--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn.hashnode.com/res/hashnode/image/upload/v1649005334768/gX_bLVyl4.png" alt="image.png" width="800" height="338"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;but if we search for an item that does not exist, we would get something like this instead:&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--YFkgre3z--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn.hashnode.com/res/hashnode/image/upload/v1649005580293/nPns6ASOi.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--YFkgre3z--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn.hashnode.com/res/hashnode/image/upload/v1649005580293/nPns6ASOi.png" alt="image.png" width="800" height="338"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;With the &lt;strong&gt;&lt;em&gt;index.Of()&lt;/em&gt;&lt;/strong&gt; method, it excepts a value as its parameter. This is perfect for finding the index in arrays of primitive types (strings, numbers, or boolean).&lt;/p&gt;

&lt;p&gt;Whereas with the &lt;strong&gt;&lt;em&gt;findIndex()&lt;/em&gt;&lt;/strong&gt; method, it expects a callback as first parameter. So we should use that if we need the index in arrays with non-primitive types (e.g. objects).&lt;/p&gt;

&lt;p&gt;Example of the &lt;strong&gt;&lt;em&gt;findIndex()&lt;/em&gt;&lt;/strong&gt; method:&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--0pf1pYMG--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn.hashnode.com/res/hashnode/image/upload/v1649009658132/DmoF-sbuj.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--0pf1pYMG--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn.hashnode.com/res/hashnode/image/upload/v1649009658132/DmoF-sbuj.png" alt="image.png" width="800" height="457"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Adding Items to The Array
&lt;/h3&gt;

&lt;p&gt;To add one or more items to an array, we use the &lt;strong&gt;&lt;em&gt;push()&lt;/em&gt;&lt;/strong&gt; method:&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--9gsr1I-2--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn.hashnode.com/res/hashnode/image/upload/v1649009504110/77s2JeEw5.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--9gsr1I-2--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn.hashnode.com/res/hashnode/image/upload/v1649009504110/77s2JeEw5.png" alt="image.png" width="800" height="299"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Say if we wanted to get the length of the new array, which means you're checking for the amount of items in the array. We would do something like this: &lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--YkjoBX-v--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn.hashnode.com/res/hashnode/image/upload/v1649009978603/_Ju_8-OA3.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--YkjoBX-v--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn.hashnode.com/res/hashnode/image/upload/v1649009978603/_Ju_8-OA3.png" alt="image.png" width="800" height="336"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;What if you wanted to add an item at the start of array, then we use the &lt;strong&gt;&lt;em&gt;unshift()&lt;/em&gt;&lt;/strong&gt; method: &lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--CIWsxoSe--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn.hashnode.com/res/hashnode/image/upload/v1649010296583/Mm3FV97J3.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--CIWsxoSe--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn.hashnode.com/res/hashnode/image/upload/v1649010296583/Mm3FV97J3.png" alt="image.png" width="800" height="299"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Removing Items in an Array
&lt;/h3&gt;

&lt;p&gt;The &lt;strong&gt;&lt;em&gt;pop()&lt;/em&gt;&lt;/strong&gt; method removes the last element from an array, and returns that element. This method  actually changes the length of the array:&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Xfb5CQyk--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn.hashnode.com/res/hashnode/image/upload/v1649010627308/ULeIC9VkH.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Xfb5CQyk--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn.hashnode.com/res/hashnode/image/upload/v1649010627308/ULeIC9VkH.png" alt="image.png" width="800" height="271"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The &lt;em&gt;**shift() *&lt;/em&gt;*method takes an item from the end of the array and removes it:&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--gOCfoywh--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn.hashnode.com/res/hashnode/image/upload/v1649010986516/7QosX9M0D.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--gOCfoywh--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn.hashnode.com/res/hashnode/image/upload/v1649010986516/7QosX9M0D.png" alt="image.png" width="800" height="253"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Say if you know the index of an item, and you want to remove said item, you can use the  &lt;strong&gt;&lt;em&gt;splice()&lt;/em&gt;&lt;/strong&gt; method:&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--CuOLcZwQ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn.hashnode.com/res/hashnode/image/upload/v1649011336109/2KLEYY8Rg.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--CuOLcZwQ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn.hashnode.com/res/hashnode/image/upload/v1649011336109/2KLEYY8Rg.png" alt="image.png" width="800" height="281"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Accessing Every Array Item
&lt;/h3&gt;

&lt;p&gt;There will be many times you'll want to access every item in the array. To do this, you can use the &lt;strong&gt;&lt;em&gt;for...of&lt;/em&gt;&lt;/strong&gt; statement:&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--8ZNiB14l--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn.hashnode.com/res/hashnode/image/upload/v1649021638835/-ZPjdlMMP.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--8ZNiB14l--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn.hashnode.com/res/hashnode/image/upload/v1649021638835/-ZPjdlMMP.png" alt="image.png" width="800" height="340"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Sometimes you'll want to make a new array with it containing the new changed items. &lt;br&gt;
You can do this using the &lt;strong&gt;&lt;em&gt;map()&lt;/em&gt;&lt;/strong&gt; method.&lt;br&gt;
Below, our function will take each element and multiply it by 3, and create a new array.&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--ral-i_r3--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn.hashnode.com/res/hashnode/image/upload/v1649021936306/tx987n0oP.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--ral-i_r3--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn.hashnode.com/res/hashnode/image/upload/v1649021936306/tx987n0oP.png" alt="image.png" width="800" height="487"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;We created a function to the &lt;strong&gt;&lt;em&gt;map()&lt;/em&gt;&lt;/strong&gt;. Map will call the function once for each item in the array, passing in it, the item. It then will add the return value from each function call to a new array, and then returns the new array at the end.&lt;/p&gt;

&lt;p&gt;Sometimes we'll want to create a new array containing items only from the original array that fall under a given criteria. &lt;br&gt;
Below we will be using &lt;strong&gt;&lt;em&gt;filter()&lt;/em&gt;&lt;/strong&gt; on fruit. Filtering through the array to find the items that consist of 6 characters or more. &lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--3ZkOZV9i--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn.hashnode.com/res/hashnode/image/upload/v1649022446548/-Pwyh9n5H.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--3ZkOZV9i--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn.hashnode.com/res/hashnode/image/upload/v1649022446548/-Pwyh9n5H.png" alt="image.png" width="800" height="373"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Just like &lt;strong&gt;&lt;em&gt;map()&lt;/em&gt;&lt;/strong&gt;, &lt;strong&gt;&lt;em&gt;filter()&lt;/em&gt;&lt;/strong&gt; method is given a function, and &lt;strong&gt;&lt;em&gt;filter()&lt;/em&gt;&lt;/strong&gt; calls the function for every item in the array,  passing in the item.  If the function returns *** true***, then the item is added to the new array. &lt;/p&gt;

&lt;p&gt;In the next blog post (pt 3), we'll end with looking at converting strings and arrays.&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>javascript</category>
      <category>beginners</category>
      <category>programming</category>
    </item>
    <item>
      <title>Working with JavaScript Arrays Pt.1</title>
      <dc:creator>Ambush3</dc:creator>
      <pubDate>Sun, 05 Jun 2022 14:21:04 +0000</pubDate>
      <link>https://dev.to/ambush3/working-with-javascript-arrays-pt1-56a7</link>
      <guid>https://dev.to/ambush3/working-with-javascript-arrays-pt1-56a7</guid>
      <description>&lt;p&gt;Knowing about Arrays are one of the most important skills you can have in a programming language, especially for one learning JavaScript.  &lt;/p&gt;

&lt;p&gt;We'll look at how with arrays, we can retrieve, add, and remove items stored in an array. &lt;/p&gt;

&lt;p&gt;Arrays are used to store a list of data items under a single variable name.&lt;br&gt;
Usually described as list-like objects, they are objects that contain multiple values stored in a list.&lt;br&gt;
Array objects are stored in variables and then be used in the same way as any other type of value. However, we can access each value inside the list individually. &lt;/p&gt;

&lt;p&gt;Arrays can be useful in such examples as if you had a dresser, and each drawer had different clothing items, and you wanted to access which drawer had what certain items.&lt;br&gt;
Another example would be if you wanted to find the many different prices of items, and wanted to send an invoice while adding up the prices together and print out the total together.  &lt;/p&gt;

&lt;h3&gt;
  
  
  Creating Arrays
&lt;/h3&gt;

&lt;p&gt;Suppose we wanted to store an array that had items that made up a skateboard:&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--YYtIhBFB--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn.hashnode.com/res/hashnode/image/upload/v1648339323165/ETOhDjcfw.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--YYtIhBFB--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn.hashnode.com/res/hashnode/image/upload/v1648339323165/ETOhDjcfw.png" alt="image.png" width="800" height="253"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Which would show you each of the items inside of the variable of skateboard.&lt;/p&gt;

&lt;p&gt;Not only can we store strings, such as what we did above, but we can also store other data types such as numbers, objects, and even other arrays.&lt;br&gt;
We can even mix other data types in a single array. &lt;br&gt;
Such an example:&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--LjHgPxfw--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn.hashnode.com/res/hashnode/image/upload/v1648339886288/iuwgAdLfC.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--LjHgPxfw--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn.hashnode.com/res/hashnode/image/upload/v1648339886288/iuwgAdLfC.png" alt="image.png" width="800" height="360"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Finding the Arrays Length
&lt;/h2&gt;

&lt;p&gt;By using the &lt;strong&gt;&lt;em&gt;length&lt;/em&gt;&lt;/strong&gt; property, we can find the length of the array.&lt;br&gt;
If wanted to find the length of the array called food, it would look something like this:&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--v9W_0h6t--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn.hashnode.com/res/hashnode/image/upload/v1648347648204/iR2WLEx9P.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--v9W_0h6t--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn.hashnode.com/res/hashnode/image/upload/v1648347648204/iR2WLEx9P.png" alt="image.png" width="800" height="281"&gt;&lt;/a&gt;&lt;br&gt;
As you see, there are 5 items inside the array of food, so 5 would be logged to the console.&lt;/p&gt;

&lt;h2&gt;
  
  
  Accessing Array Items
&lt;/h2&gt;

&lt;p&gt;You would think by looking at an array, that the items index would start with 1, but in fact, all arrays start with the item index of 0, with the second item being 1, and so on.&lt;br&gt;
Using bracket notation we can access the item index of a particular item in the array.&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--mDsrclQg--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn.hashnode.com/res/hashnode/image/upload/v1648340825875/W2kUM5aSi.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--mDsrclQg--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn.hashnode.com/res/hashnode/image/upload/v1648340825875/W2kUM5aSi.png" alt="image.png" width="800" height="320"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Say if we wanted to change the item inside of the array &lt;strong&gt;&lt;em&gt;pop&lt;/em&gt;&lt;/strong&gt;, we can do something like this.&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--7OIEybpo--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn.hashnode.com/res/hashnode/image/upload/v1648341012898/z3Ky0EOg3.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--7OIEybpo--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn.hashnode.com/res/hashnode/image/upload/v1648341012898/z3Ky0EOg3.png" alt="image.png" width="800" height="312"&gt;&lt;/a&gt;&lt;br&gt;
Here we change the first item, which is at the index of 0, to rock n rye.&lt;/p&gt;

&lt;p&gt;In the next post, I'll talk about how to find items in an array, adding items, removing items, and accessing every item. &lt;/p&gt;

</description>
      <category>webdev</category>
      <category>javascript</category>
      <category>beginners</category>
      <category>programming</category>
    </item>
  </channel>
</rss>
