<?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: Renuka Nandikolla</title>
    <description>The latest articles on DEV Community by Renuka Nandikolla (@renuma1618).</description>
    <link>https://dev.to/renuma1618</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%2F2896790%2F9e040cb2-29e1-41f3-9e47-d2e92ecb9f36.jpeg</url>
      <title>DEV Community: Renuka Nandikolla</title>
      <link>https://dev.to/renuma1618</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/renuma1618"/>
    <language>en</language>
    <item>
      <title>🧩 Next.js Application with TypeScript, Bootstrap, Supabase</title>
      <dc:creator>Renuka Nandikolla</dc:creator>
      <pubDate>Fri, 20 Jun 2025 11:05:33 +0000</pubDate>
      <link>https://dev.to/renuma1618/nextjs-application-with-typescript-bootstrap-supabase-4289</link>
      <guid>https://dev.to/renuma1618/nextjs-application-with-typescript-bootstrap-supabase-4289</guid>
      <description>&lt;h3&gt;
  
  
  A full-stack web application Project built with &lt;strong&gt;Next.js&lt;/strong&gt;, &lt;strong&gt;TypeScript&lt;/strong&gt;, &lt;strong&gt;Bootstrap&lt;/strong&gt;, and &lt;strong&gt;Supabase&lt;/strong&gt;, featuring secure user authentication, form validation, image uploads, and product management.
&lt;/h3&gt;

&lt;h2&gt;
  
  
  🚀 Features
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;User Authentication:&lt;/strong&gt; Email/password registration and login&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Social Login:&lt;/strong&gt; Google &amp;amp; GitHub authentication&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Protected Routes:&lt;/strong&gt; Access control for dashboard and profile pages&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Form Validation:&lt;/strong&gt; Client-side validation using &lt;code&gt;yup&lt;/code&gt; and &lt;code&gt;react-hook-form&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Product Management:&lt;/strong&gt; Create, read, update, and delete products&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Image Uploads:&lt;/strong&gt; Upload and display product images using Supabase Storage&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Notifications:&lt;/strong&gt; Toast messages via &lt;code&gt;react-hot-toast&lt;/code&gt; for user feedback&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Email Confirmation:&lt;/strong&gt; Users verify email before login&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Edit/Delete Profile and Products:&lt;/strong&gt; Update profile and delete products permanently&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  🛠️ Prerequisites
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Node.js&lt;/li&gt;
&lt;li&gt;npm or Yarn&lt;/li&gt;
&lt;li&gt;VS Code or preferred code editor&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  ⚙️ Getting Started
&lt;/h2&gt;

&lt;h3&gt;
  
  
  1. Initialize Project
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npx create-next-app@latest
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Use these settings during setup:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;TypeScript: Yes&lt;/li&gt;
&lt;li&gt;ESLint: Yes&lt;/li&gt;
&lt;li&gt;Tailwind CSS: Yes&lt;/li&gt;
&lt;li&gt;App Router: Yes&lt;/li&gt;
&lt;li&gt;Turbopack: No&lt;/li&gt;
&lt;li&gt;src/ directory: No&lt;/li&gt;
&lt;li&gt;Import alias: No&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  2. Install Dependencies
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npm &lt;span class="nb"&gt;install &lt;/span&gt;bootstrap react-hot-toast sweetalert2 yup react-hook-form @hookform/resolvers @supabase/supabase-js
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Bootstrap:&lt;/strong&gt; UI styling&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;React Hot Toast:&lt;/strong&gt; Toast notifications&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;SweetAlert2:&lt;/strong&gt; Stylish alert modals&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Yup:&lt;/strong&gt; Schema validation&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;React Hook Form:&lt;/strong&gt; Form handling&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;@hookform/resolvers:&lt;/strong&gt; Integrates Yup with React Hook Form&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;@supabase/supabase-js:&lt;/strong&gt; Supabase client for authentication and database&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  🔧 Supabase Configuration
&lt;/h2&gt;

&lt;h3&gt;
  
  
  1. Register and Create a Supabase Project
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;Visit &lt;a href="https://supabase.com" rel="noopener noreferrer"&gt;Supabase&lt;/a&gt; and register for an account.&lt;/li&gt;
&lt;li&gt;Click on &lt;strong&gt;"New Project"&lt;/strong&gt; to create a new Supabase project.&lt;/li&gt;
&lt;li&gt;After creation, go to &lt;strong&gt;Project Settings → API&lt;/strong&gt; and copy your &lt;strong&gt;Project URL&lt;/strong&gt; and &lt;strong&gt;Anon Key&lt;/strong&gt;.&lt;/li&gt;
&lt;/ol&gt;

&lt;blockquote&gt;
&lt;p&gt;💡 &lt;strong&gt;Note:&lt;/strong&gt; Store your credentials securely. Avoid hardcoding them in your frontend for production.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h3&gt;
  
  
  2. Email Authentication Settings
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;In Supabase dashboard, go to &lt;strong&gt;Authentication → Settings&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Under &lt;strong&gt;Email Sign up&lt;/strong&gt;:

&lt;ul&gt;
&lt;li&gt;Optionally disable "Confirm new signups" and "Secure password" for development.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;Click &lt;strong&gt;Save&lt;/strong&gt;.&lt;/li&gt;
&lt;/ol&gt;

&lt;blockquote&gt;
&lt;p&gt;⚠️ For production, always enable secure options to protect user data.&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h2&gt;
  
  
  🌱 Environment Variables Setup
&lt;/h2&gt;

&lt;h3&gt;
  
  
  1. Create a &lt;code&gt;.env.local&lt;/code&gt; File
&lt;/h3&gt;

&lt;p&gt;In your project root, create &lt;code&gt;.env.local&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;NEXT_PUBLIC_SUPABASE_URL=your-supabase-project-url
NEXT_PUBLIC_SUPABASE_ANON_KEY=your-supabase-anon-key
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  🗂️ Project Folder Structure
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;app/auth/&lt;/code&gt;: Authentication-related pages&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;components/&lt;/code&gt;: Shared UI components&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;context/&lt;/code&gt;: React Context providers for global state&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;lib/&lt;/code&gt;: Utility files, including Supabase client initialization&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  🔌 Supabase Client Setup
&lt;/h2&gt;

&lt;p&gt;Create &lt;code&gt;lib/supabaseClient.ts&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;createClient&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;@supabase/supabase-js&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;supabaseUrl&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;process&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;env&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;NEXT_PUBLIC_SUPABASE_URL&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;supabaseAnonKey&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;process&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;env&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;NEXT_PUBLIC_SUPABASE_ANON_KEY&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;supabase&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;createClient&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;supabaseUrl&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;supabaseAnonKey&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  🔑 Authentication
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Authentication Routes
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Login Page (&lt;code&gt;app/auth/login/page.tsx&lt;/code&gt;):&lt;/strong&gt; Implement login form. On success, store session token in &lt;code&gt;sessionStorage&lt;/code&gt; and redirect to dashboard.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Register Page (&lt;code&gt;app/auth/register/page.tsx&lt;/code&gt;):&lt;/strong&gt; Registration form with validation.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Profile Page (&lt;code&gt;app/auth/profile/page.tsx&lt;/code&gt;):&lt;/strong&gt; Display and update user details.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Dashboard Page (&lt;code&gt;app/auth/dashboard/page.tsx&lt;/code&gt;):&lt;/strong&gt; Protected route; redirect to &lt;code&gt;/auth/login&lt;/code&gt; if not logged in.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Social Authentication:&lt;/strong&gt; Google &amp;amp; GitHub.&lt;/li&gt;
&lt;/ul&gt;




&lt;h3&gt;
  
  
  Enable Social Authentication in Supabase
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;Go to &lt;strong&gt;Authentication → Providers&lt;/strong&gt; in Supabase.&lt;/li&gt;
&lt;li&gt;Enable &lt;strong&gt;Google&lt;/strong&gt; and &lt;strong&gt;GitHub&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Set up OAuth credentials:

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://console.developers.google.com/" rel="noopener noreferrer"&gt;Google Developer Console&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/settings/developers" rel="noopener noreferrer"&gt;GitHub Developer Settings&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ol&gt;




&lt;h3&gt;
  
  
  Logout Functionality
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Implement an &lt;code&gt;onClick&lt;/code&gt; handler for logout in &lt;code&gt;Navbar.tsx&lt;/code&gt; to clear session/local storage and redirect to login.&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  🖼️ UI Components
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Layout Setup (&lt;code&gt;app/layout.tsx&lt;/code&gt;)
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;Remove unnecessary code.&lt;/li&gt;
&lt;li&gt;Update &lt;code&gt;&amp;lt;title&amp;gt;&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Import Bootstrap CSS:&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight tsx"&gt;&lt;code&gt;  &lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;bootstrap/dist/css/bootstrap.min.css&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Import and add Toaster:&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight tsx"&gt;&lt;code&gt;  &lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;Toaster&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;react-hot-toast&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Wrap children with AppUtils context:&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  Shared Components (&lt;code&gt;components/&lt;/code&gt;)
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Navbar.tsx:&lt;/strong&gt; Navigation bar with conditional links based on auth state.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Footer.tsx:&lt;/strong&gt; Simple footer.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Loader.tsx:&lt;/strong&gt; Loader for loading states.&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  🧩 Context and Hooks
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;context/AppUtils.tsx:&lt;/strong&gt; Manages global states like &lt;code&gt;isLoggedIn&lt;/code&gt; and &lt;code&gt;AuthToken&lt;/code&gt;. Use &lt;code&gt;useEffect&lt;/code&gt; to handle session logic and redirections with &lt;code&gt;useRouter&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  ✅ Form Validation
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Register Page:&lt;/strong&gt; Use &lt;code&gt;react-hook-form&lt;/code&gt;, &lt;code&gt;yup&lt;/code&gt;, and &lt;code&gt;@hookform/resolvers/yup&lt;/code&gt; for schema validation.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Dashboard Page:&lt;/strong&gt; Define validation schema for product fields.&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  📦 Dashboard &amp;amp; Data Management
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Supabase Table:&lt;/strong&gt; Create a &lt;code&gt;products&lt;/code&gt; table in Supabase Table Editor.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Display Products:&lt;/strong&gt; In &lt;code&gt;app/dashboard/page.tsx&lt;/code&gt;, use &lt;code&gt;useState&lt;/code&gt; for products, render list, and add "Edit" and "Delete" buttons.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;C:\Users\RENUKA\Pictures\Screenshots\Screenshot (242).png&lt;/p&gt;




&lt;h2&gt;
  
  
  🖼️ Image Uploads
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Supabase Storage:&lt;/strong&gt; Create a bucket (e.g., &lt;code&gt;product-images&lt;/code&gt;).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Image Upload Implementation:&lt;/strong&gt; In dashboard, use &lt;code&gt;useState&lt;/code&gt; for preview image, handle file input, upload to Supabase Storage, and update product with image URL.&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  ▶️ Running the Application
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npm run dev
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Visit &lt;a href="http://localhost:3000" rel="noopener noreferrer"&gt;http://localhost:3000&lt;/a&gt;.&lt;/p&gt;




&lt;h2&gt;
  
  
  🛠️ Troubleshooting
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Environment Variables:&lt;/strong&gt; Ensure &lt;code&gt;.env.local&lt;/code&gt; is correct and uses &lt;code&gt;NEXT_PUBLIC_&lt;/code&gt; prefix.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Supabase API Keys:&lt;/strong&gt; Double-check URL and Anon Key.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;CORS Issues:&lt;/strong&gt; Check Supabase project settings.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Authentication Flow:&lt;/strong&gt; Verify session tokens in storage.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Redirections:&lt;/strong&gt; Check &lt;code&gt;useRouter&lt;/code&gt; paths.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Toast Messages:&lt;/strong&gt; Ensure &lt;code&gt;Toaster&lt;/code&gt; is imported and used.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Image Uploads:&lt;/strong&gt; Check Supabase Storage rules and &lt;code&gt;tsconfig.json&lt;/code&gt; paths.&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  ✨ Additional Features
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Email Confirmation:&lt;/strong&gt; After registration, users receive a confirmation email and must verify before login. On confirmation, redirect to login with a toast notification.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Edit &amp;amp; Delete User Details:&lt;/strong&gt; Users can update profile details and permanently delete products.&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  🚀 Deployment
&lt;/h2&gt;

&lt;p&gt;Deploy your Next.js application to &lt;a href="https://vercel.com/" rel="noopener noreferrer"&gt;Vercel&lt;/a&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  My Project Vercel Link - &lt;a href="https://next-supabase-app-rq9n.vercel.app/" rel="noopener noreferrer"&gt;https://next-supabase-app-rq9n.vercel.app/&lt;/a&gt;
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;🔗 Live Demo:&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
Check out the project showcased on &lt;a href="https://www.linkedin.com/in/renuka-nandikolla/" rel="noopener noreferrer"&gt;LinkedIn&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;📂 Project Code on GitHub:&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
&lt;a href="https://github.com/Renuma1618/Next-Supabase-App" rel="noopener noreferrer"&gt;https://github.com/Renuma1618/Next-Supabase-App&lt;/a&gt;&lt;/p&gt;

</description>
      <category>nextjs</category>
      <category>typescript</category>
      <category>fullstack</category>
      <category>webdev</category>
    </item>
    <item>
      <title>The Main and Tricky Concepts in JavaScript</title>
      <dc:creator>Renuka Nandikolla</dc:creator>
      <pubDate>Sat, 01 Mar 2025 16:15:03 +0000</pubDate>
      <link>https://dev.to/renuma1618/the-main-and-tricky-concepts-in-javascript-4l81</link>
      <guid>https://dev.to/renuma1618/the-main-and-tricky-concepts-in-javascript-4l81</guid>
      <description>&lt;h3&gt;
  
  
  1.scopes
&lt;/h3&gt;

&lt;h3&gt;
  
  
  2.Hoisting
&lt;/h3&gt;

&lt;h3&gt;
  
  
  3.Functions
&lt;/h3&gt;

&lt;h3&gt;
  
  
  4.Arrow Functions
&lt;/h3&gt;

&lt;h3&gt;
  
  
  5.Promises
&lt;/h3&gt;

&lt;h3&gt;
  
  
  6.Fetching API
&lt;/h3&gt;

&lt;h3&gt;
  
  
  7.Async/Await
&lt;/h3&gt;




&lt;h2&gt;
  
  
  1. Scopes 🌎
&lt;/h2&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;em&gt;Scope determines the accessibility  of variables in JavaScript.&lt;/em&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Types of Scope&lt;/strong&gt;
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Global Scope&lt;/strong&gt; 🌍: Variables declared outside any function are accessible everywhere.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Local Scope&lt;/strong&gt; 🔒: Variables declared inside a function are only accessible within that function.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Block Scope&lt;/strong&gt; 🧱: Introduced with &lt;code&gt;let&lt;/code&gt; and &lt;code&gt;const&lt;/code&gt;, variables declared inside &lt;code&gt;{}&lt;/code&gt; cannot be accessed outside.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Function Scope&lt;/strong&gt; 🎯: Variables declared using &lt;code&gt;var&lt;/code&gt; inside a function are only accessible within that function.&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  2. Hoisting 🚀
&lt;/h2&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;em&gt;Hoisting is JavaScript’s behavior of moving variable and function declarations to the top of their scope before execution.&lt;/em&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Example&lt;/strong&gt;
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;a&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// undefined (not error)&lt;/span&gt;
&lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;a&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="nf"&gt;foo&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt; &lt;span class="c1"&gt;// ✅ Works! Function declarations are hoisted&lt;/span&gt;
&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;foo&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Function Hoisted!&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="c1"&gt;// Function Expressions are **not** hoisted&lt;/span&gt;
&lt;span class="nf"&gt;bar&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt; &lt;span class="c1"&gt;// ❌ Error: bar is not a function&lt;/span&gt;
&lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;bar&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;function &lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Function Expression&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;};&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; Only function declarations are fully hoisted, but variables declared with &lt;code&gt;var&lt;/code&gt; are hoisted with &lt;code&gt;undefined&lt;/code&gt; value.&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h2&gt;
  
  
  3. Functions 🎭
&lt;/h2&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Function Declaration vs Function Expression&lt;/strong&gt;
&lt;/h3&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Feature&lt;/th&gt;
&lt;th&gt;Function Declaration&lt;/th&gt;
&lt;th&gt;Function Expression&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Hoisted?&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;✅ Yes&lt;/td&gt;
&lt;td&gt;❌ No&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Can be called before declaration?&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;✅ Yes&lt;/td&gt;
&lt;td&gt;❌ No&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Syntax&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;function func() {}&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;const func = function() {}&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Example&lt;/strong&gt;
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// Function Declaration&lt;/span&gt;
&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;greet&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="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Hello!&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="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="nf"&gt;greet&lt;/span&gt;&lt;span class="p"&gt;());&lt;/span&gt; &lt;span class="c1"&gt;// ✅ Works!&lt;/span&gt;

&lt;span class="c1"&gt;// Function Expression&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;greetExpression&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Hello from expression!&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;};&lt;/span&gt;
&lt;span class="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="nf"&gt;greetExpression&lt;/span&gt;&lt;span class="p"&gt;());&lt;/span&gt; &lt;span class="c1"&gt;// ✅ Works only after definition&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  4. Arrow Functions ➡️
&lt;/h2&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;em&gt;Arrow functions provide a more concise syntax for writing functions.&lt;/em&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Syntax&lt;/strong&gt;
&lt;/h3&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;functionName&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;parameters&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;expression&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  &lt;strong&gt;Example&lt;/strong&gt;
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// Traditional Function&lt;/span&gt;
&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;add&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;a&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;b&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;a&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nx"&gt;b&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="c1"&gt;// Arrow Function Equivalent&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;addArrow&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;a&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;b&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;a&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nx"&gt;b&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="nf"&gt;addArrow&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="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt; &lt;span class="c1"&gt;// Output: 7&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  &lt;strong&gt;Key Differences&lt;/strong&gt;
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;this&lt;/code&gt; is lexically bound&lt;/strong&gt; (inherits from the surrounding scope).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Cannot be used as constructors&lt;/strong&gt; (&lt;code&gt;new&lt;/code&gt; keyword).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;No &lt;code&gt;arguments&lt;/code&gt; object available&lt;/strong&gt;.&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  5. Promises 🤝
&lt;/h2&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;em&gt;A Promise is an object that represents the eventual completion or failure of an asynchronous operation.&lt;/em&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;States of a Promise&lt;/strong&gt;
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Pending&lt;/strong&gt; 🟡 - Initial state, before the result is available.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Fulfilled&lt;/strong&gt; ✅ - The operation was successful.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Rejected&lt;/strong&gt; ❌ - The operation failed.&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Why use Promises?&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;✔️ Handle asynchronous operations efficiently.&lt;br&gt;&lt;br&gt;
✔️ Avoid callback hell.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Example&lt;/strong&gt;
&lt;/h3&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;myPromise&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;Promise&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="nx"&gt;resolve&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;reject&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;success&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nf"&gt;setTimeout&lt;/span&gt;&lt;span class="p"&gt;(()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;success&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="nf"&gt;resolve&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Promise resolved! ✅&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
        &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="nf"&gt;reject&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Promise rejected! ❌&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="p"&gt;},&lt;/span&gt; &lt;span class="mi"&gt;2000&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;

&lt;span class="nx"&gt;myPromise&lt;/span&gt;
    &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;then&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;response&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;response&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;  &lt;span class="c1"&gt;// Runs if resolved&lt;/span&gt;
    &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="k"&gt;catch&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;error&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;error&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt;      &lt;span class="c1"&gt;// Runs if rejected&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  6. Fetching Data from an API 🌍
&lt;/h2&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;em&gt;Fetch is used to request data from a server.&lt;/em&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Example&lt;/strong&gt;
&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;fetch&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;https://jsonplaceholder.typicode.com/posts/1&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;then&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;response&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;response&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;json&lt;/span&gt;&lt;span class="p"&gt;())&lt;/span&gt; &lt;span class="c1"&gt;// Convert response to JSON&lt;/span&gt;
    &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;then&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;data&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;data&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;   &lt;span class="c1"&gt;// Log data&lt;/span&gt;
    &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="k"&gt;catch&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;error&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Error:&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;error&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;It returns a Promise, which we handle using &lt;code&gt;.then()&lt;/code&gt; and &lt;code&gt;.catch()&lt;/code&gt;.&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h2&gt;
  
  
  7. Async/Await ⏳
&lt;/h2&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;em&gt;&lt;code&gt;async/await&lt;/code&gt; makes handling asynchronous code cleaner and more readable.&lt;/em&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Example&lt;/strong&gt;
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;fetchData&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;try&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;response&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nf"&gt;fetch&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;https://jsonplaceholder.typicode.com/posts/1&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
        &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;data&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;response&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;json&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;data&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;catch &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;error&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Error:&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;error&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nf"&gt;fetchData&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  &lt;strong&gt;Why use &lt;code&gt;async/await&lt;/code&gt;?&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;✔️ Avoids callback hell&lt;br&gt;&lt;br&gt;
✔️ Improves readability&lt;br&gt;&lt;br&gt;
✔️ Easier error handling using &lt;code&gt;try...catch&lt;/code&gt;  &lt;/p&gt;




&lt;h2&gt;
  
  
  &lt;strong&gt;🚀 Summary&lt;/strong&gt;
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Scope&lt;/strong&gt;: Determines where variables are accessible.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Hoisting&lt;/strong&gt;: Moves function declarations and &lt;code&gt;var&lt;/code&gt; variables to the top before execution.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Function Declarations vs Expressions&lt;/strong&gt;: Declarations are hoisted, expressions are not.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Arrow Functions&lt;/strong&gt;: Shorter syntax, no &lt;code&gt;this&lt;/code&gt; binding.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Promises&lt;/strong&gt;: Handle async operations with &lt;code&gt;.then()&lt;/code&gt; and &lt;code&gt;.catch()&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Fetch API&lt;/strong&gt;: Used for making network requests.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Async/Await&lt;/strong&gt;: Syntactic sugar over Promises for cleaner async code.&lt;/li&gt;
&lt;/ul&gt;

&lt;blockquote&gt;
&lt;p&gt;🔹 &lt;em&gt;Master these concepts, and you're on your way to becoming a JavaScript pro!&lt;/em&gt; 🚀&lt;/p&gt;
&lt;/blockquote&gt;

</description>
      <category>webdev</category>
      <category>programming</category>
      <category>javascript</category>
      <category>beginners</category>
    </item>
    <item>
      <title>JavaScript vs TypeScript:</title>
      <dc:creator>Renuka Nandikolla</dc:creator>
      <pubDate>Mon, 24 Feb 2025 16:54:57 +0000</pubDate>
      <link>https://dev.to/renuma1618/javascript-vs-typescript-1heh</link>
      <guid>https://dev.to/renuma1618/javascript-vs-typescript-1heh</guid>
      <description>&lt;h3&gt;
  
  
  ✨ Introduction
&lt;/h3&gt;

&lt;p&gt;JavaScript is a &lt;strong&gt;dynamic&lt;/strong&gt;, loosely typed language widely used for web development. TypeScript, on the other hand, is a strongly typed &lt;strong&gt;superset of JavaScript&lt;/strong&gt; that provides static typing and other powerful features.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;em&gt;" 🎯 TypeScript is JavaScript with syntax for types." – Microsoft&lt;/em&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  key differences
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Feature&lt;/th&gt;
&lt;th&gt;🟡JavaScript&lt;/th&gt;
&lt;th&gt;🔵Typescript&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;📌Type System&lt;/td&gt;
&lt;td&gt;Dynamically typed&lt;/td&gt;
&lt;td&gt;Statically typed&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;⚡Compilation&lt;/td&gt;
&lt;td&gt;Runs directly in browsers&lt;/td&gt;
&lt;td&gt;Needs to be compiled to JavaScript&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;🐞Error Detection&lt;/td&gt;
&lt;td&gt;Detected at runtime&lt;/td&gt;
&lt;td&gt;Detected at compile-time&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;🛠Tooling &amp;amp; Debugging&lt;/td&gt;
&lt;td&gt;Limited static analysis&lt;/td&gt;
&lt;td&gt;Better IntelliSense &amp;amp; error detection&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;🎓Learning Curve&lt;/td&gt;
&lt;td&gt;Easier for beginners&lt;/td&gt;
&lt;td&gt;Requires learning types &amp;amp; compilation&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;📈Code Scalability&lt;/td&gt;
&lt;td&gt;Less maintainable for large projects&lt;/td&gt;
&lt;td&gt;Better for large-scale applications&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;
&lt;/blockquote&gt;

&lt;h3&gt;
  
  
  🚀Why Choose TypeScript Over JavaScript?
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;&lt;em&gt;Improved Code Quality&lt;/em&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Detects errors before execution&lt;/li&gt;
&lt;li&gt;Reduces debugging time&lt;/li&gt;
&lt;li&gt;Better Developer Experience&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;em&gt;Offers IntelliSense for better code suggestions&lt;/em&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Provides better code documentation with types&lt;/li&gt;
&lt;li&gt;Enhanced Maintainability&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;em&gt;Code is more structured and readable&lt;/em&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Helps in large-scale applications with multiple developers&lt;/li&gt;
&lt;li&gt;Static Typing Benefits&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;h4&gt;
  
  
  Extensions to Save
&lt;/h4&gt;

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

&lt;h4&gt;
  
  
  📝JavaScript Example
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; var name = "Renuka"; // Can store any value
console.log(name);  // Output: Renuka

name = 25; // No error, but may cause issues later
console.log(name);  // Output: 25
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  TypeScript Example
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;var name: string = "Renuka"; // Explicitly defined as a string
console.log(name); // Output: Renuka

// name = 25; // ❌ Error: Type 'number' is not assignable to type 'string'
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h1&gt;
  
  
  JavaScript or TypeScript🤔?
&lt;/h1&gt;

&lt;blockquote&gt;
&lt;p&gt;✅ Use JavaScript if you're working on small projects or quick prototypes.&lt;br&gt;
✅ Use TypeScript for large applications, enterprise projects, or when working in teams.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;a href="https://www.geeksforgeeks.org/difference-between-typescript-and-javascript/" rel="noopener noreferrer"&gt;🔗Click and Understand JavaScript and TypeScript better &lt;br&gt;
&lt;/a&gt;&lt;/p&gt;




&lt;blockquote&gt;
&lt;h2&gt;
  
  
  🙋‍♀️About Me
&lt;/h2&gt;

&lt;p&gt;👩‍💻Computer Science graduate and Frontend Developer with a strong foundation in full-stack development, Frontend development and agile methodologies. Passionate about building innovative and reliable products that empower users. Experienced in modern, responsive interfaces using React.js.&lt;br&gt;
&lt;em&gt;Lets Connect👉&lt;/em&gt; &lt;em&gt;&lt;a href="https://www.linkedin.com/in/renuka-nandikolla" rel="noopener noreferrer"&gt;Linkdin&lt;/a&gt;&lt;/em&gt; &amp;amp; &lt;em&gt;&lt;a href="//renuka1682003@gmail.com"&gt;Email&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;
&lt;/blockquote&gt;

</description>
    </item>
  </channel>
</rss>
