<?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: Ezzdin Atef</title>
    <description>The latest articles on DEV Community by Ezzdin Atef (@ezzdinatef).</description>
    <link>https://dev.to/ezzdinatef</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.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F202509%2F0eb8f462-5dac-4cc8-a14a-a3071cab081e.jpeg</url>
      <title>DEV Community: Ezzdin Atef</title>
      <link>https://dev.to/ezzdinatef</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/ezzdinatef"/>
    <language>en</language>
    <item>
      <title>I got tired of writing blog posts in VS Code, so I built my own Markdown editor</title>
      <dc:creator>Ezzdin Atef</dc:creator>
      <pubDate>Mon, 16 Nov 2026 14:18:36 +0000</pubDate>
      <link>https://dev.to/ezzdinatef/i-got-tired-of-writing-blog-posts-in-vs-code-so-i-built-my-own-markdown-editor-o6j</link>
      <guid>https://dev.to/ezzdinatef/i-got-tired-of-writing-blog-posts-in-vs-code-so-i-built-my-own-markdown-editor-o6j</guid>
      <description>&lt;p&gt;For a long time my "blogging setup" was VS Code, a terminal, and a lot of patience.&lt;/p&gt;

&lt;p&gt;I'd open my site's repo, find the posts folder, copy the frontmatter from an older post, fix the date, forget a tag, drag an image into the wrong folder, run &lt;code&gt;git add&lt;/code&gt;, write a commit message I'd regret later, push, and then notice a typo on the live site. Every single time.&lt;/p&gt;

&lt;p&gt;And because I write in both Arabic and English, there was an extra layer of pain. Most editors handle right-to-left text badly. Mix an Arabic sentence with a code snippet or an English term and the cursor starts jumping around like it's trying to escape.&lt;/p&gt;

&lt;p&gt;So I built &lt;a href="https://mditoor.com/" rel="noopener noreferrer"&gt;Mditoor&lt;/a&gt;. It's a desktop app for writing Markdown and MDX content, and it's free and open source (MIT). This post is a tour of what it does, because the feature list has grown a lot more than I planned.&lt;/p&gt;

&lt;h2&gt;
  
  
  What it is, in one paragraph
&lt;/h2&gt;

&lt;p&gt;Mditoor is a local-first desktop studio (Tauri + React + Rust) where you can:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Write posts directly inside your static site's repo (Next.js, Astro, Hugo, Jekyll and friends),&lt;/li&gt;
&lt;li&gt;Keep personal or study notes in plain Markdown folders, or&lt;/li&gt;
&lt;li&gt;Write and publish straight to DEV, even if you don't have a site at all.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Your files stay plain &lt;code&gt;.md&lt;/code&gt; / &lt;code&gt;.mdx&lt;/code&gt; on your disk. No database, no account, no cloud lock-in.&lt;/p&gt;

&lt;h2&gt;
  
  
  The editor
&lt;/h2&gt;

&lt;p&gt;This is where I spend most of my time, so it got the most love.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Block editor or raw Markdown.&lt;/strong&gt; Write in a clean block-based editor, or switch to plain Markdown when you want full control. Same file either way.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Edit, Split, and Preview modes.&lt;/strong&gt; Write, see both side by side, or just read.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Slash commands.&lt;/strong&gt; Type &lt;code&gt;/&lt;/code&gt; and start filtering. &lt;code&gt;/im&lt;/code&gt; gets you an image, &lt;code&gt;/h2&lt;/code&gt; a heading. Faster than reaching for the mouse.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Block menus.&lt;/strong&gt; Right-click a block, or hit the &lt;code&gt;...&lt;/code&gt; button, to turn it into a heading, list, quote, callout or code block. There's a drag handle to reorder blocks too.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Floating selection toolbar.&lt;/strong&gt; Select text and the formatting options show up right there, plus a context menu for text.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Keyboard shortcuts&lt;/strong&gt; for the usual formatting stuff.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Auto-save&lt;/strong&gt; with an interval you choose, and a clear saved / unsaved indicator so you always know where you stand.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Word count&lt;/strong&gt; on every post.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;You can tune how it looks: light, dark, or follow the system theme, a choice of sans-serif or monospace for the writing surface, several font sizes, and line height (compact, comfortable, relaxed).&lt;/p&gt;

&lt;h2&gt;
  
  
  Built for Arabic and English (RTL + LTR)
&lt;/h2&gt;

&lt;p&gt;This is the reason the app exists, honestly.&lt;/p&gt;

&lt;p&gt;Mditoor detects text direction &lt;strong&gt;per block&lt;/strong&gt;. An Arabic paragraph is right-to-left, the English one under it is left-to-right, and the code block stays where code belongs. It works the same in the editor and in the preview. You don't toggle anything.&lt;/p&gt;

&lt;p&gt;You also get a separate Arabic font setting (Cairo, Noto Sans Arabic, Readex Pro are bundled), and the whole UI is available in English, Arabic and French.&lt;/p&gt;

&lt;p&gt;If you write in Hebrew, Persian or Urdu, this should help you too. I'd love to hear how it goes.&lt;/p&gt;

&lt;h2&gt;
  
  
  Frontmatter without the YAML headaches
&lt;/h2&gt;

&lt;p&gt;I don't know anyone who enjoys hand-editing frontmatter.&lt;/p&gt;

&lt;p&gt;In Mditoor you define your metadata fields once per workspace, and every post gets a form instead of raw YAML or TOML. Supported field types:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;text&lt;/code&gt;, &lt;code&gt;number&lt;/code&gt;, &lt;code&gt;boolean&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;date&lt;/code&gt; (with a date picker)&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;select&lt;/code&gt; (like &lt;code&gt;draft&lt;/code&gt; / &lt;code&gt;published&lt;/code&gt;)&lt;/li&gt;
&lt;li&gt;&lt;code&gt;tags&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;image&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Fields can be required, and the sidebar tells you when something is missing ("2 required missing") before you ship a post with no title. There's also a frontmatter preview if you want to see what's actually being written to the file.&lt;/p&gt;

&lt;p&gt;The config lives in a &lt;code&gt;.mditoor.json&lt;/code&gt; file in your posts folder, so you can commit it and your teammates get the same fields.&lt;/p&gt;

&lt;h2&gt;
  
  
  Framework presets
&lt;/h2&gt;

&lt;p&gt;When you create a workspace, Mditoor tries to detect your framework and suggests the posts folder. Each preset sets the post layout, file extension, frontmatter format and where images go:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Preset&lt;/th&gt;
&lt;th&gt;Post file&lt;/th&gt;
&lt;th&gt;Frontmatter&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Next.js&lt;/td&gt;
&lt;td&gt;&lt;code&gt;&amp;lt;slug&amp;gt;/index.mdx&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;YAML&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Astro&lt;/td&gt;
&lt;td&gt;&lt;code&gt;&amp;lt;slug&amp;gt;.md&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;YAML&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Hugo&lt;/td&gt;
&lt;td&gt;&lt;code&gt;&amp;lt;slug&amp;gt;/index.md&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;TOML&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Jekyll&lt;/td&gt;
&lt;td&gt;&lt;code&gt;YYYY-MM-DD-&amp;lt;slug&amp;gt;.md&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;YAML&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Docusaurus&lt;/td&gt;
&lt;td&gt;&lt;code&gt;&amp;lt;slug&amp;gt;/index.md&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;YAML&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Eleventy&lt;/td&gt;
&lt;td&gt;&lt;code&gt;&amp;lt;slug&amp;gt;.md&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;YAML&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Nuxt Content&lt;/td&gt;
&lt;td&gt;&lt;code&gt;&amp;lt;slug&amp;gt;.md&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;YAML&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Generic&lt;/td&gt;
&lt;td&gt;&lt;code&gt;&amp;lt;slug&amp;gt;/index.mdx&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;YAML&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Everything can be changed afterwards. Next.js is the one I test the most (it's what my own blog runs on), so if your setup doesn't fit, please open an issue with an example layout.&lt;/p&gt;

&lt;h2&gt;
  
  
  Git, without leaving the app
&lt;/h2&gt;

&lt;p&gt;This was the second big reason. I wanted "write, commit, push" without opening a terminal.&lt;/p&gt;

&lt;p&gt;The Git panel shows status and a diff view, and lets you stage, commit, pull and push. Nothing fancy, just the 95% of git I actually use while writing.&lt;/p&gt;

&lt;h2&gt;
  
  
  Images that go where they should
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Drag images straight into the editor.&lt;/li&gt;
&lt;li&gt;Optionally &lt;strong&gt;resize and compress&lt;/strong&gt; them on import, so you stop shipping 6 MB screenshots.&lt;/li&gt;
&lt;li&gt;Store them next to the post, in a &lt;code&gt;public/&lt;/code&gt; folder, or upload them to &lt;strong&gt;any S3-compatible bucket&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;The &lt;strong&gt;asset gallery&lt;/strong&gt; shows every image in the workspace and, my favorite part, which ones aren't used anywhere anymore.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;S3 credentials are encrypted in the config file with a key that never leaves your machine, so it's safe to commit &lt;code&gt;.mditoor.json&lt;/code&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  A small SEO check before you publish
&lt;/h2&gt;

&lt;p&gt;Each post has an SEO panel with a search result preview and a short checklist:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Title length&lt;/li&gt;
&lt;li&gt;Meta description length&lt;/li&gt;
&lt;li&gt;Clean URL slug&lt;/li&gt;
&lt;li&gt;A single main heading&lt;/li&gt;
&lt;li&gt;Uses subheadings (H2)&lt;/li&gt;
&lt;li&gt;Enough content (300+ words)&lt;/li&gt;
&lt;li&gt;Images have alt text&lt;/li&gt;
&lt;li&gt;Contains links&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;It gives you a simple score ("Looking great", "Almost there", "Needs attention"). It's not trying to be an SEO tool, it's just the stuff I kept forgetting.&lt;/p&gt;

&lt;h2&gt;
  
  
  Ideas board
&lt;/h2&gt;

&lt;p&gt;Half my posts start as a random thought at 1am. The ideas board is a place to dump those, move them through stages, search them, and turn one into a real draft when you're ready. Ideas are saved in a &lt;code&gt;.mditoor-ideas.json&lt;/code&gt; next to your posts.&lt;/p&gt;

&lt;h2&gt;
  
  
  DEV workspaces (yes, like this one)
&lt;/h2&gt;

&lt;p&gt;Not everyone has a personal blog, and that's fine. Plenty of people use their DEV profile as their blog.&lt;/p&gt;

&lt;p&gt;So you can create a &lt;strong&gt;DEV workspace&lt;/strong&gt;, paste an API key from your DEV settings, and Mditoor will:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Verify the account and store the key encrypted locally&lt;/li&gt;
&lt;li&gt;Import your existing articles&lt;/li&gt;
&lt;li&gt;Let you write drafts &lt;strong&gt;offline&lt;/strong&gt;, saved locally first&lt;/li&gt;
&lt;li&gt;Sync with explicit &lt;strong&gt;Save to DEV&lt;/strong&gt; and &lt;strong&gt;Publish on DEV&lt;/strong&gt; buttons. Nothing goes out unless you click.&lt;/li&gt;
&lt;li&gt;Ask you which version to keep if the local and remote copies both changed&lt;/li&gt;
&lt;li&gt;Upload cover and inline images through your own S3 bucket, since DEV's API needs public image URLs&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;And if you do have your own site, there's &lt;strong&gt;cross-posting&lt;/strong&gt;: send a post from your local project to DEV, with an optional canonical URL pointing back to the original. Good for SEO, good for not having to copy-paste.&lt;/p&gt;

&lt;h2&gt;
  
  
  Notes workspaces
&lt;/h2&gt;

&lt;p&gt;The newest addition. Not everything I write is a blog post. Lecture notes, research, a journal, random wiki pages for myself.&lt;/p&gt;

&lt;p&gt;A Notes workspace is just a folder of Markdown files, nested as deep as you want. You can start from a template:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Empty&lt;/strong&gt;: just the folder&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Study&lt;/strong&gt;: &lt;code&gt;inbox/&lt;/code&gt; and a sample course folder&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Journal&lt;/strong&gt;: a folder per year with today's note ready&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Research&lt;/strong&gt;: &lt;code&gt;papers/&lt;/code&gt;, &lt;code&gt;ideas/&lt;/code&gt;, &lt;code&gt;reading-list/&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Notes get a lighter frontmatter form (title, tags, created date, status like &lt;code&gt;todo / learning / done&lt;/code&gt;) instead of the SEO panel. There's a folder tree with breadcrumbs, search across every folder, and you can move a note just by editing its path. Folders can only be deleted when they're empty, so you can't nuke your notes by accident.&lt;/p&gt;

&lt;p&gt;Want backup or sync between machines? Leave "Track with Git" on, paste a remote, and commit and push from the Git tab. Since it's all plain files, the folder also works fine with any other Markdown tool.&lt;/p&gt;

&lt;h2&gt;
  
  
  The small stuff
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Command palette&lt;/strong&gt; with &lt;code&gt;Ctrl/Cmd + K&lt;/code&gt; to jump anywhere&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Auto-updates&lt;/strong&gt; so you don't have to keep checking the releases page&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Resizable sidebar&lt;/strong&gt; (double-click to reset)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;No tracking.&lt;/strong&gt; The app makes no network requests of its own, except the git operations, DEV syncs and S3 uploads you trigger.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Where it runs
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Windows&lt;/strong&gt;: prebuilt installer. This is my main platform.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;macOS&lt;/strong&gt;: universal &lt;code&gt;.dmg&lt;/code&gt; for Intel and Apple Silicon. Alpha, not tested as much.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Linux&lt;/strong&gt;: &lt;code&gt;.AppImage&lt;/code&gt; and &lt;code&gt;.deb&lt;/code&gt;. Also alpha.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Full disclosure: the builds aren't code-signed yet, so Windows SmartScreen and macOS will complain the first time. The README explains how to get past that, or you can build it from source.&lt;/p&gt;

&lt;h2&gt;
  
  
  Try it, break it, tell me
&lt;/h2&gt;

&lt;p&gt;It's still early and I'm building it in my free time, so there are rough edges. That's exactly why I'm posting this.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Website and downloads: &lt;a href="https://mditoor.com/" rel="noopener noreferrer"&gt;mditoor.com&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Source code: &lt;a href="https://github.com/ezzdin-atef/mditoor" rel="noopener noreferrer"&gt;github.com/ezzdin-atef/mditoor&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If you try it, I'd really like to know what annoyed you. Bug reports, feature ideas, and especially help testing on macOS and Linux would mean a lot. And if you write in a right-to-left language, I want to hear from you most of all.&lt;/p&gt;

&lt;p&gt;Thanks for reading.&lt;/p&gt;

</description>
      <category>markdown</category>
      <category>opensource</category>
      <category>writing</category>
      <category>productivity</category>
    </item>
    <item>
      <title>eCommerce Database Design</title>
      <dc:creator>Ezzdin Atef</dc:creator>
      <pubDate>Fri, 17 Nov 2023 19:04:14 +0000</pubDate>
      <link>https://dev.to/ezzdinatef/ecommerce-database-design-1ggc</link>
      <guid>https://dev.to/ezzdinatef/ecommerce-database-design-1ggc</guid>
      <description>&lt;p&gt;Building eCommerce is one of the most famous web application that we build as it got so famous, well known, and the need of it is became more than ever for ordering and shipping products to your home online.&lt;/p&gt;

&lt;p&gt;One of the most challenges that I have faces while building many eCommerce application is the complicity that it gain with more features that's required from the client and we have to add. That's made me think about the pros and cons of my structure specially the database design and started ask my self many questions like, Is my design is suitable for these requirement?, Did I get the most clean structure I can get?, Is this affect with performance and loading data efficiency?.&lt;/p&gt;

&lt;p&gt;Until this moment I write this blog, this the database design that I get into conclusion to be best fit to the needs that I have faced before (until I got new project with more complicated requirement 🤡).&lt;/p&gt;

&lt;h2&gt;
  
  
  Our Project Description &amp;amp; Requirements
&lt;/h2&gt;

&lt;p&gt;First of all, as any application we have users that can register and login to our eCommerce application. Every user have one or more addresses. They have also favorite or Wishlist, Orders list to list there orders and its status, and Cart list of all the products that's ready to be ordered.&lt;/p&gt;

&lt;p&gt;We have categories and sub categories (2 levels of categories) and each have a name and description.&lt;/p&gt;

&lt;p&gt;For sure we have products and this have many things:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Basic information of the product like: name, description, price, summary, cover image, ...etc.&lt;/li&gt;
&lt;li&gt;Product gallery which consist of many images of the product.&lt;/li&gt;
&lt;li&gt;Every product may have some attributes like sizes, and colors.&lt;/li&gt;
&lt;li&gt;Some products that have many colors will have image gallery for every color separated.&lt;/li&gt;
&lt;li&gt;Every color, size, or both might there prices vary. let's say that the blue t-shirt will cost &lt;code&gt;20$&lt;/code&gt; but the red t-shirt will cost &lt;code&gt;22$&lt;/code&gt; . even the xl blue t-shirt will cost &lt;code&gt;22$&lt;/code&gt; but the XXL blue t-shirt will cost &lt;code&gt;26$&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Every color and size have limited quantity stock like we might have from the XXL blue t-shirt 3 items but XXXL blue t-shirt just 1 item.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;When user make an order will choose one of his addresses with the order and he might pay online with any supported way like visa or something else (will integrate with payment gateway).&lt;/p&gt;

&lt;p&gt;When the order is out for delivery then the quantity of all products will decrease.&lt;/p&gt;

&lt;p&gt;Now, that's all with the requirements of the project so let's get our mind around it.&lt;/p&gt;

&lt;h2&gt;
  
  
  Database Designing
&lt;/h2&gt;

&lt;p&gt;As we notice from the previous section that the most complex part is the product, here where the game play go xD.&lt;/p&gt;

&lt;p&gt;Let's start from the beginning of our database design.&lt;/p&gt;

&lt;h3&gt;
  
  
  Users Table
&lt;/h3&gt;

&lt;p&gt;Let's start with the users table and its related information.&lt;/p&gt;

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

&lt;p&gt;Here we just have 2 tables, one for users information details, and the other one for the addresses that's associated to the user and linked in &lt;code&gt;one to many&lt;/code&gt; relationship using the &lt;code&gt;user_id&lt;/code&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  Categories Table
&lt;/h3&gt;

&lt;p&gt;Now in the categories table, We have 2 tables one for main categories, and the other for sub categories. sub categories table associated to the categories in &lt;code&gt;one to many&lt;/code&gt; relationship.&lt;/p&gt;

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

&lt;h3&gt;
  
  
  Products Table
&lt;/h3&gt;

&lt;p&gt;Now, The products table, Let’s start with simple structure that have the basic information of the product and linked within the categories (will be linked in &lt;code&gt;many to many&lt;/code&gt; relationship with sub categories table). See image bellow.&lt;/p&gt;

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

&lt;p&gt;Let’s try to take a more higher look, as mention above the products will have many different attribute (in our situation here are colors, and sizes) and they might be with different prices range, So let’s remove the price column from the products table because that will be linked in other table.&lt;/p&gt;

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

&lt;p&gt;As we notice above, we added new table called &lt;code&gt;product_attributes&lt;/code&gt; that will hold all product attributes types and there values from different colors and sizes.&lt;/p&gt;

&lt;p&gt;Then will create &lt;code&gt;product_skus&lt;/code&gt; table that will link between products and the attribute together as we added 2 columns both point to the &lt;code&gt;product_attributes&lt;/code&gt; table but, one for colors and the other for sizes (we can add more if we need to).&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Note: We may split the &lt;code&gt;product_attributes&lt;/code&gt; table to 2 more table like &lt;code&gt;product_colors&lt;/code&gt;, and &lt;code&gt;product_sizes&lt;/code&gt; but I think of &lt;code&gt;product_attributes&lt;/code&gt; table idea more easily extendable as we can add more attributes sizes in same table but will add just one more column in &lt;code&gt;products_skus&lt;/code&gt; table.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Each &lt;code&gt;product_skus&lt;/code&gt; entity have a price and quantity value that may vary between every attributes variation.&lt;/p&gt;

&lt;h3&gt;
  
  
  Wishlist Table
&lt;/h3&gt;

&lt;p&gt;The Wishlist table is quite simple as we will just store the &lt;code&gt;product_id&lt;/code&gt; and the &lt;code&gt;user_id&lt;/code&gt;. That’s it 😀.&lt;/p&gt;

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

&lt;h3&gt;
  
  
  Cart Table
&lt;/h3&gt;

&lt;p&gt;This table is what’s holding the products that customer wants to buy and order so we will have a table called &lt;code&gt;cart&lt;/code&gt; which connected to the &lt;code&gt;user&lt;/code&gt; table and have total cost attribute.&lt;/p&gt;

&lt;p&gt;The other table is &lt;code&gt;cart_item&lt;/code&gt; which is linked to the cart table and carry the &lt;code&gt;product&lt;/code&gt; and &lt;code&gt;product sku&lt;/code&gt; tables and the quantity required by the customer.&lt;/p&gt;

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

&lt;p&gt;As shown above, the 2 tables are very simple.&lt;/p&gt;

&lt;h3&gt;
  
  
  Orders Table
&lt;/h3&gt;

&lt;p&gt;The order table is same as cart tables we have &lt;code&gt;order&lt;/code&gt; and &lt;code&gt;order_item&lt;/code&gt; (but will call the &lt;code&gt;order&lt;/code&gt; as &lt;code&gt;order_details&lt;/code&gt;). Just will have one more table that will be responsible for the payments will be named &lt;code&gt;payment_details&lt;/code&gt; which will hold all the payment information from order, amount, provider, and status. &lt;/p&gt;

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

&lt;p&gt;As shown above, this is the order and payment tables to store all needed info that we need for now or event we can add more attributes as required.&lt;/p&gt;

&lt;h3&gt;
  
  
  Final Schema
&lt;/h3&gt;

&lt;p&gt;Now let’s look into the big picture of our schema.&lt;/p&gt;

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

&lt;p&gt;Here’s the preview link to play with it on &lt;a href="https://dbdiagram.io/d/eCommerce-Database-Design-65521cb47d8bbd6465131f01" rel="noopener noreferrer"&gt;dbdiagram.io&lt;/a&gt;&lt;/p&gt;

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

&lt;p&gt;Here we reach to the end of this article, I hope you enjoyed. If you have any suggestion or comments, please write it down and I'll be happy to share thoughts with you. &lt;/p&gt;

&lt;p&gt;See you again 😀;&lt;/p&gt;

</description>
      <category>database</category>
      <category>backend</category>
      <category>performance</category>
    </item>
    <item>
      <title>What's Pure Function in JavaScript</title>
      <dc:creator>Ezzdin Atef</dc:creator>
      <pubDate>Sun, 02 Apr 2023 12:23:48 +0000</pubDate>
      <link>https://dev.to/ezzdinatef/whats-pure-function-in-javascript-44ck</link>
      <guid>https://dev.to/ezzdinatef/whats-pure-function-in-javascript-44ck</guid>
      <description>&lt;p&gt;Hello World,&lt;/p&gt;

&lt;p&gt;One of the most known questions, especially in interviews, is about pure functions and what they are… so we will talk about pure functions in this article.&lt;/p&gt;

&lt;h2&gt;
  
  
  what are pure functions?
&lt;/h2&gt;

&lt;p&gt;It’s the atomic building block of functional programming. they are very simple and easy to test.&lt;/p&gt;

&lt;p&gt;The function can be called a pure function if these conditions are applied:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The same inputs&amp;nbsp;always&amp;nbsp;return the same outputs&lt;/li&gt;
&lt;li&gt;No side effects&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Let’s focus on each of them:&lt;/p&gt;

&lt;h3&gt;
  
  
  The same inputs&amp;nbsp;always&amp;nbsp;return the same outputs
&lt;/h3&gt;

&lt;p&gt;This means that we always get the same output whenever we use the function and pass the same input.&lt;/p&gt;

&lt;p&gt;for example, we have this function.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;

&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;sum&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;x&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;y&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;x&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nx"&gt;y&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nf"&gt;sum&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// will return always 5&lt;/span&gt;


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;whenever we pass the same input &lt;code&gt;2, 3&lt;/code&gt;, we get the same output &lt;code&gt;5&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;But in the following example.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;

&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;num&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;sum&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;x&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;num&lt;/span&gt;&lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="nx"&gt;x&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nf"&gt;sum&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// will return 7&lt;/span&gt;
&lt;span class="nf"&gt;sum&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// will return 9&lt;/span&gt;


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;we have a shared state here, which is a bad practice (we don’t use it unless we need to do things that way) because we can’t predict the return value of the function now, and became not a pure function.&lt;/p&gt;

&lt;p&gt;So in summary, a pure function is a function that returns the same output always whenever we call it and pass the same input.&lt;/p&gt;

&lt;h3&gt;
  
  
  No side effects
&lt;/h3&gt;

&lt;p&gt;the side effects of a function are one of the following:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Mutating your input&lt;/li&gt;
&lt;li&gt;use &lt;code&gt;console.log&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;HTTP calls (AJAX/fetch)&lt;/li&gt;
&lt;li&gt;Changing the filesystem&lt;/li&gt;
&lt;li&gt;Querying the DOM&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;In general, the function implementation should be only about calculating the final output and nothing else.&lt;/p&gt;

&lt;p&gt;Note: we should not always use pure function and it’s not the best solution as may you think, because we might need to call HTTP requests, change the file system, or query the DOM tree.&lt;/p&gt;

&lt;p&gt;That’s it for today’s article, if you have any suggestions, then don’t hesitate to contact me anytime.&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>beginners</category>
      <category>programming</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>Slice vs Splice in JavaScript</title>
      <dc:creator>Ezzdin Atef</dc:creator>
      <pubDate>Wed, 23 Jun 2021 12:34:34 +0000</pubDate>
      <link>https://dev.to/ezzdinatef/slice-vs-splice-in-javascript-42ef</link>
      <guid>https://dev.to/ezzdinatef/slice-vs-splice-in-javascript-42ef</guid>
      <description>&lt;p&gt;Hello everyone 👋&lt;/p&gt;

&lt;p&gt;when I started learning JavaScript, I was confused about slice &amp;amp; splice methods so, thus I will try to explain it simply without going deep in it so you understand it easily without any confusion.&lt;/p&gt;

&lt;h2&gt;
  
  
  Slice
&lt;/h2&gt;

&lt;p&gt;Slice means to cut something into pieces or slices. In JavaScript, we use to cut a part of the array as we need just a partial part of the array.&lt;/p&gt;

&lt;h3&gt;
  
  
  Syntax
&lt;/h3&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;

&lt;span class="nf"&gt;slice&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;start&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;end&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;slice method tasks 2 parameters:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;start: the start index of the array where I should strat cut it.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;end: the end index where I should stop cutting&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Note: That the end index will not be a part of the sliced array&lt;/p&gt;

&lt;h3&gt;
  
  
  Examples
&lt;/h3&gt;

&lt;p&gt;In The First Example, I want to get from index 1 to the element before index 4&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;arr&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Item 1&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Item 2&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Item 3&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Item 4&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Item 5&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Item 6&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Item 7&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Item 8&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;];&lt;/span&gt;

&lt;span class="nx"&gt;arr&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;slice&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;  &lt;span class="c1"&gt;// will return ["Item 2", "Item 3", "Item 4"]&lt;/span&gt;


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;In The Second Example, we want to get from index 3 to the end of the array&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;arr&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Item 1&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Item 2&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Item 3&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Item 4&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Item 5&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Item 6&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Item 7&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Item 8&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;];&lt;/span&gt;

&lt;span class="nx"&gt;arr&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;slice&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;  &lt;span class="c1"&gt;// will return ["Item 4", "Item 5", "Item 6", "Item 7", "Item 8"]&lt;/span&gt;


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;so here we didn't specify the end parameter and when we do that he will take the rest of the array until the end.&lt;/p&gt;

&lt;h2&gt;
  
  
  Splice
&lt;/h2&gt;

&lt;p&gt;Splice means to connect or join. we use it if we want to add something to the array but in a specific place unlike push or unshift which adds new elements to the end or the beginning of the array. and we use It also to remove something from the array from a specific place.&lt;/p&gt;

&lt;h3&gt;
  
  
  Syntax
&lt;/h3&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;

&lt;span class="nf"&gt;splice&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;start&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;deleteCount&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;item1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;item2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;itemN&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;start: the start index of the array where I should start changing it.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;deleteCount: the number of elements that I want to delete and if I don't want to remove anything we simply pass 0&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Then the rest of the parameters is the elements we want to add to the array ^_^&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Examples
&lt;/h3&gt;

&lt;p&gt;In The First Example, I just want to remove 3 elements from the array starting from the element of index 2&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;arr&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Item 1&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Item 2&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Item 3&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Item 4&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Item 5&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Item 6&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Item 7&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Item 8&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;];&lt;/span&gt;
&lt;span class="nx"&gt;arr&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;splice&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;arr&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// will return ["Item 1", "Item 2", "Item 6", "Item 7", "Item 8"]&lt;/span&gt;


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;In The Second Example, we want to add some new elements from index 5 without removing any elements from the array so will be the first element I will add will be in index 5&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;arr&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Item 1&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Item 2&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Item 3&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Item 4&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Item 5&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Item 6&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Item 7&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Item 8&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;];&lt;/span&gt;
&lt;span class="nx"&gt;arr&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;splice&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;item 9&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;item 10&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;arr&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// will return  ["Item 1", "Item 2", "Item 3", "Item 4", "Item 5", "item 9", "item 10", "Item 6", "Item 7", "Item 8"]&lt;/span&gt;


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;In The Third Example, Now let us remove some elements and replace it with other new elements 😄&lt;/p&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;

&lt;p&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;arr&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Item 1&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Item 2&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Item 3&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Item 4&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Item 5&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Item 6&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Item 7&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Item 8&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;];&lt;/span&gt;&lt;br&gt;
&lt;span class="nx"&gt;arr&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;splice&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;item 9&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;item 10&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;&lt;br&gt;
&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;arr&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// will return  ["Item 1", "Item 2", "item 9", "item 10", "Item 6", "Item 7", "Item 8"]&lt;/span&gt;&lt;/p&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;h2&gt;
&lt;br&gt;
  &lt;br&gt;
  &lt;br&gt;
  Conclusion&lt;br&gt;
&lt;/h2&gt;

&lt;p&gt;So that's it 😀. Slice returns part of an array while splice adds &amp;amp; removes some elements of an array from a specific index.&lt;br&gt;
Of course, there is a more complex example &amp;amp; usage for them which you can check out later to have a deep understanding of it.&lt;/p&gt;

&lt;p&gt;I hope you find this article helpful 🤗&lt;/p&gt;

&lt;p&gt;see you next time ✌&lt;/p&gt;

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