<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Kavyabhat on Medium]]></title>
        <description><![CDATA[Stories by Kavyabhat on Medium]]></description>
        <link>https://medium.com/@kavyabhat98?source=rss-401590a4d40a------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*ZuGWunKbYn8-xk-eOD321Q.jpeg</url>
            <title>Stories by Kavyabhat on Medium</title>
            <link>https://medium.com/@kavyabhat98?source=rss-401590a4d40a------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Thu, 19 Nov 2026 10:23:44 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@kavyabhat98/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[TypeScript Basics for JavaScript Developers]]></title>
            <link>https://medium.com/@kavyabhat98/typescript-basics-for-javascript-developers-423b9ebea580?source=rss-401590a4d40a------2</link>
            <guid isPermaLink="false">https://medium.com/p/423b9ebea580</guid>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[react]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[typescript]]></category>
            <category><![CDATA[software-development]]></category>
            <dc:creator><![CDATA[Kavyabhat]]></dc:creator>
            <pubDate>Thu, 21 May 2026 14:04:46 GMT</pubDate>
            <atom:updated>2026-05-21T14:04:46.245Z</atom:updated>
            <content:encoded><![CDATA[<blockquote><em>“TypeScript is no longer just a ‘nice-to-have’ skill. Many companies now expect frontend developers to write type-safe and scalable applications.”</em></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*iMEUoaKoGCcO3NnVmdvypA.png" /></figure><blockquote><strong><em>Why TypeScript?</em></strong></blockquote><p>JavaScript Problem</p><pre>function add(a, b) {<br>  return a + b;<br>}<br><br>console.log(add(10, &quot;20&quot;));</pre><p>output : 1020</p><p>JavaScript does not check data types.<br> Instead of adding numbers, it converts 10 into a string and joins them together.</p><p>This can create unexpected bugs in large applications.</p><p>TypeScript Solution</p><pre>function add(a: number, b: number): number {<br>  return a + b;<br>}<br><br>console.log(add(10, 20));</pre><p>Here:</p><ul><li>a: number → parameter must be a number</li><li>b: number → parameter must be a number</li><li>: number after function → return value must be a number</li></ul><pre>add(10, &quot;20&quot;);</pre><p>TypeScript immediately shows an error before running the code.</p><p>That is the biggest advantage of TypeScript.</p><blockquote><strong>Variables and Types</strong></blockquote><h4><strong>JavaScript</strong></h4><pre>let username = &quot;Kavya&quot;;</pre><p>JavaScript automatically guesses the type.</p><h4><strong>TypeScript</strong></h4><pre>let username: string = &quot;Kavya&quot;;</pre><p>Here:</p><ul><li>string defines the variable type</li><li>TypeScript ensures only strings can be assigned</li></ul><pre>username = 100;</pre><p>TypeScript shows: <em>Type ‘number’ is not assignable to type ‘string’</em></p><blockquote><strong>Arrays</strong></blockquote><h4>JavaScript</h4><pre>let skills = [&quot;React&quot;, 10, true];</pre><p>Different data types are allowed.</p><h4><strong>TypeScript</strong></h4><pre>let skills: string[] = [&quot;React&quot;, &quot;TypeScript&quot;];</pre><p>string[] means this array can only contain strings.</p><pre>skills.push(10);</pre><p>TypeScript prevents this mistake.</p><blockquote><strong>Objects</strong></blockquote><h4>JavaScript</h4><pre>const user = {<br>  name: &quot;Kavya&quot;,<br>  age: 25<br>};</pre><p>No validation exists.</p><blockquote><strong>TypeScript</strong></blockquote><pre>const user: { name: string; age: number } = {<br>  name: &quot;Kavya&quot;,<br>  age: 25<br>};</pre><p>TypeScript checks:</p><ul><li>name must be string</li><li>age must be number</li></ul><pre>age: &quot;25&quot;</pre><p>This gives an error.</p><blockquote><strong>Interfaces</strong></blockquote><p>Interfaces help define reusable object structures.</p><pre>interface User {<br>  name: string;<br>  age: number;<br>}<br><br>const user1: User = {<br>  name: &quot;Kavya&quot;,<br>  age: 25<br>};</pre><p>Instead of repeating object types everywhere, we create one reusable structure.</p><p>Benefits:</p><ul><li>Cleaner code</li><li>Easier maintenance</li><li>Better scalability</li></ul><blockquote><strong>Optional Properties</strong></blockquote><pre>interface Employee {<br>  name: string;<br>  company?: string;<br>}</pre><p>? means optional.</p><pre>const emp1 = {<br>  name: &quot;Kavya&quot;<br>};<br><br>const emp2 = {<br>  name: &quot;Kavya&quot;,<br>  company: &quot;Infosys&quot;<br>};</pre><p>Both work correctly.</p><blockquote><strong>Union Types</strong></blockquote><p>Sometimes variables can store multiple types.</p><pre>let id: string | number;<br><br>id = 101;<br>id = &quot;EMP101&quot;;</pre><p>let id: string | number;</p><p>id = 101;<br>id = “EMP101”;</p><p>Useful in APIs and database IDs.</p><blockquote><strong>Functions in TypeScript</strong></blockquote><pre>function greet(name: string): string {<br>  return `Hello ${name}`;<br>}</pre><ul><li>name: string → only string allowed</li><li>return type : string</li></ul><pre>greet(100);</pre><p>TypeScript prevents invalid input.</p><blockquote><strong>Any vs Unknown</strong></blockquote><h4>Any</h4><pre>let value: any = 10;<br><br>value = &quot;Hello&quot;;<br>value = true;</pre><p>any disables TypeScript checking.</p><p>Too much any makes TypeScript useless.</p><h4>Unknown</h4><pre>let value: unknown = &quot;Hello&quot;;</pre><p>unknown is safer because TypeScript forces validation before usage.</p><pre>if (typeof value === &quot;string&quot;) {<br>  console.log(value.toUpperCase());<br>}</pre><blockquote><strong>Generics</strong></blockquote><p>Generics create reusable functions.</p><pre>function identity&lt;T&gt;(value: T): T {<br>  return value;<br>}<br><br>identity&lt;string&gt;(&quot;Hello&quot;);<br>identity&lt;number&gt;(100);</pre><p>&lt;T&gt; represents a placeholder type.</p><p>Benefits:</p><ul><li>Reusable code</li><li>Type safety</li><li>Flexible functions</li></ul><p>TypeScript does not replace JavaScript.<br> It improves JavaScript by adding:</p><ul><li>type safety</li><li>better tooling</li><li>fewer bugs</li><li>improved scalability</li></ul><p>For JavaScript developers, TypeScript feels familiar but much safer for building modern applications.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=423b9ebea580" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[From Complexity ❌to Simplicity✅ Transitioning Your Redux Codebase to Redux Toolkit ✨]]></title>
            <link>https://blog.stackademic.com/from-complexity-to-simplicity-transitioning-your-redux-codebase-to-redux-toolkit-f3bda1cd46f7?source=rss-401590a4d40a------2</link>
            <guid isPermaLink="false">https://medium.com/p/f3bda1cd46f7</guid>
            <category><![CDATA[redux-toolkit]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[redux]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[front-end-development]]></category>
            <dc:creator><![CDATA[Kavyabhat]]></dc:creator>
            <pubDate>Thu, 22 Feb 2024 05:08:15 GMT</pubDate>
            <atom:updated>2024-02-25T05:26:37.451Z</atom:updated>
            <content:encoded><![CDATA[<blockquote><strong>What is Redux Toolkit?</strong></blockquote><p>Redux Toolkit is like a toolbox for making Redux easier to use. It provides helpful functions and tools that simplify writing Redux code, which is used for managing state.</p><p>In simple terms, Redux Toolkit is a set of tools that make working with Redux simpler and more efficient, allowing you to focus on building your application logic rather than getting down in boilerplate code. It’s particularly helpful for managing complex state in larger applications or projects.</p><blockquote><strong>Why to use?</strong></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/850/1*0b5sXLnroihBd2tJcA-AeA.png" /></figure><p><strong>Less Boilerplate →</strong> <em>Redux traditionally involves writing a lot of boilerplate code for setting up the store, defining actions, reducers, etc. Redux Toolkit provides utilities that help reduce this boilerplate, making your codebase cleaner and easier to understand.</em></p><p><strong>Simplified Syntax →</strong><em>With Redux Toolkit, you can define reducers, actions, and the store in a more concise and readable way. It provides functions like </em><em>createSlice, </em><em>createAction, and </em><em>configureStore that abstract away some of the complexity of Redux.</em></p><p><strong>Performance Optimizations →</strong> <em>Redux Toolkit includes optimizations under the hood that can help improve the performance of your Redux application, such as memoization and efficient handling of immutable updates.</em></p><p><strong>Integrated Async Handling →</strong> <em>Dealing with asynchronous operations, like fetching data from a server, is easier with Redux Toolkit. It provides built-in tools to handle async logic without extra setup.</em>Redux Toolkit provides utilities like createAsyncThunk to simplify managing asynchronous logic in your Redux store.</p><p><strong>Immutability Made Easy →</strong><em>It includes built-in support for handling immutable updates with the “immer” library, simplifying the process of updating state immutably.</em></p><p><strong>Integration with React →</strong> <em>If you’re using React for your front-end development, Redux Toolkit integrates seamlessly with React applications. It provides hooks like </em><em>useDispatch and </em><em>useSelector that make it easy to interact with your Redux store from your React components.</em></p><p><strong>Improved Developer Experience →</strong> <em>With Redux Toolkit, developers can write Redux code more efficiently and with fewer lines of code. This can lead to a better developer experience, as it reduces load associated with managing complex state management logic.</em></p><p><strong>Compatible with existing Redux code →</strong> <em>Redux Toolkit is fully compatible with existing Redux code. You can gradually migrate your Redux codebase to Redux Toolkit without rewriting everything from scratch.</em></p><blockquote><strong>Diagram for Redux Toolkit</strong></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_QuqlfDqvknXyFMd53PHJA.png" /></figure><blockquote><strong>Installation</strong></blockquote><p>npm install @reduxjs/toolkit</p><p>npm install react-redux</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/670/1*2TC70TaaQsoLz-N11wLjvQ.png" /></figure><blockquote><strong>files</strong></blockquote><ol><li>app/store.js → “configureStore” from <strong>@reduxjs/toolkit</strong></li><li>features/todo/todoSlice.js → “createSlice” from <strong>@reduxjs/toolkit</strong></li><li>components/AddTodo.js → “useDispatch” from <strong>react-redux</strong></li><li>components/Todos.js → “UseSelector” from <strong>react-redux</strong></li><li>index.js → “Provider” from <strong>react-redux</strong></li></ol><blockquote><strong>Source Code</strong></blockquote><p><strong>Simple Todo example</strong></p><blockquote>⚠️<strong>Live Demo</strong>: <a href="https://spectacular-seahorse-d0d2a2.netlify.app/">https://spectacular-seahorse-d0d2a2.netlify.app/</a></blockquote><blockquote>⚠️<strong>Source Code Link</strong>: <a href="https://github.com/kavyabhat99/TodoReduxToolKit">https://github.com/kavyabhat99/TodoReduxToolKit</a></blockquote><p><strong>app/store.js</strong></p><pre>import { configureStore } from &#39;@reduxjs/toolkit&#39;<br>import todoReducer from &#39;./features/todo/todoSlice&#39;<br>export const store = configureStore({<br>    reducer: todoReducer,<br>})</pre><p><em>Configure a store (centralized for managing state) we can find the whole application state in store. import configureStore from ‘@reduxjs/toolkit’ library and also add the reducer in it there can be many reducer but in this example its only one.</em></p><p><strong>features/todo/todoSlice.js</strong></p><pre>import { createSlice, nanoid } from &#39;@reduxjs/toolkit&#39;<br><br>const initialState = {<br>    todos: [],<br>}<br><br>export const todoSlice = createSlice({<br>    name: &quot;todo&quot;,<br>    initialState,<br>    reducers: {<br>        addTodo: (state, action) =&gt; {<br>            const todo = {<br>                id: nanoid(),<br>                text: action.payload<br>            }<br>            state.todos.push(todo)<br>        },<br>        removeTodo: (state, action) =&gt; {<br>            state.todos = state.todos.filter((todo) =&gt; {<br>                return todo.id !== action.payload<br>            })<br>        }<br>    }<br>})<br><br>export const { addTodo, removeTodo } = todoSlice.actions;<br>export default todoSlice.reducer;</pre><p><em>Import </em><strong><em>createSlice</em></strong><em> and </em><strong><em>nanoid</em></strong><em> from the </em><a href="http://twitter.com/reduxjs/toolkit"><strong><em>@reduxjs/toolkit</em></strong></a><strong><em> </em></strong><em>library. createSlice is a function for creating Redux slices, and nanoid is used for generating unique IDs for todo items.</em></p><p><em>Define the </em><strong><em>initial state</em></strong><em> of the todo slice, which includes an empty array for storing todo items.</em></p><p><em>Use to </em><strong><em>createSlice </em></strong><em>define a slice named &quot;todo&quot;. The slice includes initial state and reducers.</em></p><p><em>Two reducers are defined: </em><strong><em>addTodo and removeTodo.</em></strong></p><p><strong><em>addTodo</em></strong><em>: This reducer is responsible for adding a new todo item to the state. It generates a unique ID using nanoid() and adds a new todo object to the todos array in the state.<br></em><strong><em>removeTodo:</em></strong><em> This reducer removes a todo item from the state based on the provided ID. It filters out the todo with the matching ID from the todos array.</em></p><p><em>Export </em><strong><em>addTodo</em></strong><em> and </em><strong><em>removeTodo</em></strong><em> actions along with the reducer function from the slice.</em></p><p><strong>components/AddTodo.js</strong></p><pre>import React, { useState } from &#39;react&#39;<br>import { useDispatch } from &#39;react-redux&#39;<br>import { addTodo } from &#39;../app/features/todo/todoSlice&#39;<br><br>function AddTodo() {<br>  const [input, setInput] = useState(&#39;&#39;)<br>  const dispatch = useDispatch()<br><br>  const addTodoHandler = (e) =&gt; {<br>    e.preventDefault();<br>    dispatch(addTodo(input))<br>    setInput(&#39;&#39;)<br>  }<br>  return (<br>    &lt;div className=&#39;p-4&#39;&gt;<br>      &lt;form onSubmit={addTodoHandler}&gt;<br>        &lt;input className=&#39;m-4 border-solid border-2 border-indigo-600&#39;<br>          type=&quot;text&quot;<br>          value={input}<br>          onChange={(e) =&gt; setInput(e.target.value)}<br>        &gt;&lt;/input&gt;<br>        &lt;button type=&quot;submit&quot; className=&#39;bg-sky-500 rounded p-2 text-white&#39; &gt;Add Todo&lt;/button&gt;<br>      &lt;/form&gt;<br>    &lt;/div&gt;<br>  )<br>}<br><br>export default AddTodo</pre><p><em>Obtain the </em><strong><em>dispatch</em></strong><em> function using the </em><strong><em>useDispatch</em></strong><em> hook from React-Redux. This function is used to dispatch actions to the Redux store.</em></p><p><em>The </em><strong><em>addTodo </em></strong><em>action creator is a function that creates an action object. In this case, it expects a payload, which is the input variable. This payload typically contains the data necessary for the reducer to update the state.</em></p><p><em>So, </em><strong><em>dispatch(addTodo(input))</em></strong><em> dispatches an action to add a new todo item to the store, with the input value being the text of the todo item. This action will be processed by the Redux store, which will update the state accordingly based on the logic defined in the reducer associated with the addTodo action.</em></p><p><strong>components/Todos.js</strong></p><pre>import React from &#39;react&#39;<br>import { useSelector } from &#39;react-redux&#39;<br>import { useDispatch } from &#39;react-redux&#39;<br>import { removeTodo } from &#39;../app/features/todo/todoSlice&#39;<br><br>function Todos() {<br><br>  const todos = useSelector(state =&gt; state.todos)<br>  const dispatch = useDispatch()<br>  console.log(todos)<br><br>  return (<br>    &lt;div&gt;<br>      {<br>        todos.map((todo) =&gt; {<br>          return &lt;div className=&quot;bg-gray-400 ml-[400px] mr-[400px] border-solid border-2 flex rounded-lg&quot; key={todo.id}&gt;<br>            &lt;div className=&#39;text-white m-6&#39;&gt;{todo.text}&lt;/div&gt;<br>            &lt;button className=&#39;bg-red-500 m-4 rounded p-2 text-white&#39; onClick={() =&gt; dispatch(removeTodo(todo.id))}&gt;Delete&lt;/button&gt;<br>          &lt;/div&gt;<br>        })<br>      }<br>    &lt;/div&gt;<br>  )<br>}<br><br>export default Todos</pre><p><em>Import necessary dependencies from React and Redux, including </em><strong><em>useSelector and useDispatch</em></strong><em> hooks, as well as the </em><strong><em>removeTodo action</em></strong><em> from the todo slice.</em></p><p><em>Use the </em><strong><em>useSelector</em></strong><em> hook to extract the todos array from the Redux store state. This hook provides access to the Redux store state, and </em><strong><em>state.todos</em></strong><em> implies that the todo slice is stored under the key </em><strong><em>todos</em></strong><em> in the Redux store.</em></p><p><em>Obtain the dispatch function using the </em><strong><em>useDispatch</em></strong><em> hook from React-Redux. This function is used to </em><strong><em>dispatch</em></strong><em> actions to the Redux store. Clicking the “Delete” button triggers the</em><strong><em> removeTodo</em></strong><em> action with the todo item’s</em><strong><em> id as the payload</em></strong><em>, which will remove the corresponding todo item from the Redux store.</em></p><p>index.js</p><pre>import React from &#39;react&#39;;<br>import ReactDOM from &#39;react-dom/client&#39;;<br>import &#39;./index.css&#39;;<br>import App from &#39;./App&#39;;<br>import reportWebVitals from &#39;./reportWebVitals&#39;;<br>import { Provider } from &quot;react-redux&quot;<br>import { store } from &#39;./app/store&#39;;<br><br>const root = ReactDOM.createRoot(document.getElementById(&#39;root&#39;));<br>root.render(<br>  &lt;React.StrictMode&gt;<br>    &lt;Provider store={store}&gt;<br>      &lt;App /&gt;<br>    &lt;/Provider&gt;<br>  &lt;/React.StrictMode&gt;<br>);<br><br>// If you want to start measuring performance in your app, pass a function<br>// to log results (for example: reportWebVitals(console.log))<br>// or send to an analytics endpoint. Learn more: https://bit.ly/CRA-vitals<br>reportWebVitals();</pre><p><strong><em>&lt;Provider store={store}&gt;</em></strong><em> this is a component provided by React Redux. It accepts a </em><strong><em>store prop</em></strong><em>, which should be your Redux store. The &lt;Provider&gt; component ensures that the Redux store is available to all components nested within it.</em></p><p>App.js</p><pre>import &#39;./App.css&#39;;<br>import Todos from &#39;./components/Todos&#39;;<br>import AddTodo from &#39;./components/AddTodo&#39;;<br><br>function App() {<br>  return (<br>    &lt;div className=&quot;App p-[100px]&quot;&gt;<br>      &lt;AddTodo /&gt;<br>      &lt;Todos /&gt;<br>    &lt;/div&gt;<br>  );<br>}<br><br>export default App;<br></pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lzyMgXhKvE1YWzKdUyNjQw.png" /></figure><p>Add Todos in input box</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lYos0fSWjcTVvHUZBMTEXw.png" /></figure><p>Todos added</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KU73tm19uTEtTxY_ogfWjQ.png" /></figure><p>Todos Deleted</p><blockquote><strong>summary</strong></blockquote><p>Redux Toolkit is a powerful library that simplifies and streamlines Redux development by providing utilities and abstractions to help manage state, handle actions, and create reducers more efficiently. It includes features like createSlice, createReducer, createAction, and configureStore to reduce boilerplate code and improve developer productivity. With Redux Toolkit, developers can write cleaner, more concise Redux code while still benefiting from the predictability and scalability that Redux offers. By abstracting away many of the complexities of Redux setup and configuration.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/250/1*5q-a2IdIqmjM3quusv147A.gif" /></figure><h3>Stackademic 🎓</h3><p>Thank you for reading until the end. Before you go:</p><ul><li>Please consider <strong>clapping</strong> and <strong>following</strong> the writer! 👏</li><li>Follow us <a href="https://twitter.com/stackademichq"><strong>X</strong></a><strong> | </strong><a href="https://www.linkedin.com/company/stackademic"><strong>LinkedIn</strong></a><strong> | </strong><a href="https://www.youtube.com/c/stackademic"><strong>YouTube</strong></a><strong> | </strong><a href="https://discord.gg/in-plain-english-709094664682340443"><strong>Discord</strong></a></li><li>Visit our other platforms: <a href="https://plainenglish.io/"><strong>In Plain English</strong></a><strong> | </strong><a href="https://cofeed.app/"><strong>CoFeed</strong></a><strong> | </strong><a href="https://venturemagazine.net/"><strong>Venture</strong></a><strong> | </strong><a href="https://blog.cubed.run/"><strong>Cubed</strong></a></li><li>More content at <a href="https://stackademic.com/"><strong>Stackademic.com</strong></a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f3bda1cd46f7" width="1" height="1" alt=""><hr><p><a href="https://blog.stackademic.com/from-complexity-to-simplicity-transitioning-your-redux-codebase-to-redux-toolkit-f3bda1cd46f7">From Complexity ❌to Simplicity✅ Transitioning Your Redux Codebase to Redux Toolkit 🚀✨</a> was originally published in <a href="https://blog.stackademic.com/">Stackademic</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Introduction to JavaScript Arrays!]]></title>
            <link>https://blog.stackademic.com/introduction-to-javascript-arrays-8b50ac37e40b?source=rss-401590a4d40a------2</link>
            <guid isPermaLink="false">https://medium.com/p/8b50ac37e40b</guid>
            <category><![CDATA[datastrucutre]]></category>
            <category><![CDATA[computer-science]]></category>
            <category><![CDATA[arrays]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[javascript]]></category>
            <dc:creator><![CDATA[Kavyabhat]]></dc:creator>
            <pubDate>Wed, 27 Dec 2023 11:26:33 GMT</pubDate>
            <atom:updated>2023-12-28T01:34:48.451Z</atom:updated>
            <content:encoded><![CDATA[<p>Arrays in JavaScript are special objects that allow you to store multiple values in a single variable. They are widely used data structure in JavaScript. Arrays can hold various types of data, including numbers, strings, objects, and even other arrays.</p><blockquote><strong>Array Declaration</strong></blockquote><ol><li>let arr = new Array();</li><li>let arr = [ ];</li></ol><ul><li><em>Array </em><strong><em>indexing</em></strong><em> starts from “</em><strong><em>0</em></strong><em>”.</em></li><li><em>Array can include </em><strong><em>any data type</em></strong><em> including objects.</em></li><li><strong><em>Array.length</em></strong><em> gives no of elements in an Array.</em></li></ul><pre>let person = {<br>  name: &quot;kavya&quot;,<br>  age: 25<br>}<br><br>let array = [&quot;apple&quot;, &quot;banana&quot;, &quot;chery&quot;,person];<br>console.log(array[0], array[1], array[2], array[3].age,array[3].name,array.length,array[4])</pre><p>output:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/823/1*eiKlc_1Q8XLIjH8uEtCjXg.png" /></figure><blockquote><strong>Arrays — Add and Remove Elements</strong></blockquote><pre>let array = [&quot;apple&quot;, &quot;banana&quot;, &quot;cherry&quot;];<br><br>//Add to the end of the Array<br>array.push(&quot;orange&quot;, &quot;mango&quot;, &quot;Watermelon&quot;);<br>console.log(array);<br><br>//Remove from End of the Array<br>array.pop();<br>array.pop();<br>console.log(array);<br><br>//Add to the top of the array (Beginning)<br>array.unshift(&quot;blueberry&quot;);<br>console.log(array);<br><br>//Romove from the top of the array (Beginning)<br>array.shift();<br>array.shift();<br>console.log(array);</pre><p>output:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/715/1*UV_ib27_qpemtSmWXiwbKg.png" /></figure><blockquote><strong>Looping in Array</strong></blockquote><pre>let array = [&quot;apple&quot;, &quot;banana&quot;, &quot;cherry&quot;];<br><br>for (var i = 0; i &lt; array.length; i++) {<br>  console.log(array[i]);<br>}<br><br>let j = 0;<br>while (j &lt; array.length) {<br>  console.log(array[j]);<br>  j++;<br>}</pre><p>output:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/709/1*VxYD47eUtuVl49mGO-EpqA.png" /></figure><blockquote><strong>Inbuilt loop Methods</strong></blockquote><pre>const numbers = [1, 2, 3, 4, 5];<br><br>//forEach<br>numbers.forEach((item, index, array) =&gt; {<br>  return (item)<br>})<br>console.log(&quot;ForEach output&quot;,numbers);<br><br>//Map<br>const mapnums = numbers.map((item, index, array) =&gt; {<br>  return (item + 5)<br>})<br>console.log(&quot;Map output&quot;,mapnums);<br><br>//filter<br>const filternums = numbers.filter((item, index, array) =&gt; {<br>  return item &gt; 3;<br>})<br>console.log(&quot;filter output&quot;,filternums);<br><br>//reduce<br>const reducenums = numbers.reduce((acc, current, index, array) =&gt; {<br>  return current + acc<br>}, 0)<br>console.log(&quot;reduce output&quot;,reducenums);<br><br>//some<br>const somenums = numbers.some((item, index, array) =&gt; {<br>  return item &gt; 3;<br>})<br>console.log(&quot;some output&quot;,somenums);<br><br>//every<br>const everynums = numbers.every((item, index, array) =&gt; {<br>  return item &gt; 3;<br>})<br>console.log(&quot;every output&quot;,everynums);<br><br>//find<br>const findnums = numbers.find((item, index, array) =&gt; {<br>  return item &gt; 3;<br>})<br>console.log(&quot;find output&quot;,findnums);<br><br>//findIndex<br>const findindexnums = numbers.findIndex((item)=&gt;{<br>  return item === 3;<br>})<br>console.log(&quot;findIndex output&quot;, findindexnums);</pre><p>output:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/346/1*4XwsLZhoEOobXM4a-n-xdg.png" /></figure><blockquote><strong>Spread and Rest operators</strong></blockquote><pre>const nums1 = [1, 2, 3];<br>const nums2 = [4, 5, 6, 7];<br><br>//Spread<br>const FinalNums = [...nums1, ...nums2]<br>console.log(FinalNums)<br><br>//Rest<br>function test(...numbers) {<br>  return numbers;<br>}<br>console.log(test(nums1, nums2, 5, &quot;Kavya&quot;))</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/751/1*ntFZtsFu77Bz8muAG7WwcA.png" /></figure><blockquote><strong>More array Methods</strong></blockquote><pre>const nums1 = [1, 2, 3];<br>const nums2 = [4, 5, 6, 7];<br>const array = [&quot;orange&quot;, &quot;banana&quot;, &quot;cherry&quot;];<br><br>//concat<br>const Final = nums1.concat(nums2, array);<br>console.log(Final)<br><br>//Array.from<br>const str = &#39;Hello&#39;;<br>const strArray = Array.from(str);<br>console.log(strArray);<br><br>//slice<br>const newarr1 = array.slice(0, 2);<br>const newarr2 = array.slice(-1);<br>const newarr3 = array.slice(-2);<br>console.log(newarr1, newarr2, newarr3);<br><br>//splice<br>array.splice(1, 2, &quot;apple&quot;);<br>console.log(array);<br><br>//fill<br>const fillarr = [1, 3, 3, 4];<br>const result = fillarr.fill(0, 2);<br>console.log(result);<br><br>//flat<br>const flatarr = [1, 3, 3, 4, [1, 2],[ [1, 2]]];<br>const res = flatarr.flat(2);<br>console.log(res);<br><br>//reverse<br>const rev = [1,2,3,4,5,6];<br>rev.reverse();<br>console.log(rev);<br><br>//sort<br>const unsorted=[5,2,10,7,3,1];<br>unsorted.sort((a,b)=&gt;a-b);<br>console.log(unsorted);</pre><p>output:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/460/1*RaGjK-LfZcbpvaQ6f8V6UQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/250/1*5q-a2IdIqmjM3quusv147A.gif" /></figure><h3>Stackademic</h3><p><em>Thank you for reading until the end. Before you go:</em></p><ul><li><em>Please consider </em><strong><em>clapping</em></strong><em> and </em><strong><em>following</em></strong><em> the writer! 👏</em></li><li><em>Follow us on </em><a href="https://twitter.com/stackademichq"><strong><em>Twitter(X)</em></strong></a><em>, </em><a href="https://www.linkedin.com/company/stackademic"><strong><em>LinkedIn</em></strong></a><em>, and </em><a href="https://www.youtube.com/c/stackademic"><strong><em>YouTube</em></strong></a><strong><em>.</em></strong></li><li><em>Visit </em><a href="http://stackademic.com/"><strong><em>Stackademic.com</em></strong></a><em> to find out more about how we are democratizing free programming education around the world.</em></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8b50ac37e40b" width="1" height="1" alt=""><hr><p><a href="https://blog.stackademic.com/introduction-to-javascript-arrays-8b50ac37e40b">Introduction to JavaScript Arrays!🚀</a> was originally published in <a href="https://blog.stackademic.com/">Stackademic</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Unlocking JavaScript’s Asynchronous Potential : Callbacks , Promises  and ⚡️Async/Await ⌛]]></title>
            <link>https://blog.stackademic.com/unlocking-javascripts-asynchronous-potential-callbacks-promises-and-%EF%B8%8Fasync-await-538ca66d1fe5?source=rss-401590a4d40a------2</link>
            <guid isPermaLink="false">https://medium.com/p/538ca66d1fe5</guid>
            <category><![CDATA[code]]></category>
            <category><![CDATA[asynchronous]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[javascript-development]]></category>
            <dc:creator><![CDATA[Kavyabhat]]></dc:creator>
            <pubDate>Sat, 16 Dec 2023 08:10:52 GMT</pubDate>
            <atom:updated>2023-12-18T01:49:56.668Z</atom:updated>
            <content:encoded><![CDATA[<h3>Unlocking JavaScript’s Asynchronous Potential : Callbacks 🔄, Promises 🤝 and ⚡️Async/Await 🚀⌛</h3><blockquote><strong>callbacks</strong></blockquote><p><strong>callback </strong>in JavaScript is a function that is passed as an argument to another function and is intended to be executed after a specific task or event. Instead of calling the function directly, you pass it as an argument to another function, and that function will call it back later.</p><p><em>lets take simple example to understand callbacks.</em></p><pre>console.log(&quot;start&quot;)<br>function Subscribe(blogername) {<br>  setTimeout(() =&gt; {<br>    return(`Follow ${blogername} for Frontend content`)<br>  }, 1000)<br>}<br>const name = Subscribe(&quot;kavya Bhat&quot;)<br>console.log(name)<br>console.log(&quot;stop&quot;)</pre><p>output:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/175/1*QvKxH3oGP3aPLgiTkiY6lw.png" /></figure><p><em>here we get undefined for</em><strong><em> name</em></strong><em> to fix this we can use</em><strong><em> callbacks !!</em></strong></p><pre>console.log(&quot;start&quot;)<br><br>function Subscribe(blogername, cb) {<br>  setTimeout(() =&gt; {<br>    cb(`Follow ${blogername} for Frontend content`)<br>  }, 1000)<br>}<br><br>Subscribe(&quot;kavya Bhat&quot;, function(name) {<br>  console.log(name)<br>})<br><br>console.log(&quot;stop&quot;)</pre><p>output:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/450/1*x2wUSFljw-eJVMKhmrexTQ.png" /></figure><p><em>suppose if we have more </em><strong><em>Functions ? then?</em></strong></p><p><em>lets see some code snippet to understand it</em></p><p><em>here we have 3 Functions </em><strong><em>Subscribe , Like and share </em></strong><em>so here share is not executed till Subscribe and Like finishes execution same way for Like, Like is not executed till Subscribe finishes.</em></p><pre>console.log(&quot;start&quot;)<br><br>function Subscribe(blogername, cb) {<br>  setTimeout(() =&gt; {<br>    cb(`Follow ${blogername} for Frontend content`)<br>  }, 1000)<br>}<br><br>function Like(blog, cb) {<br>  setTimeout(() =&gt; {<br>    cb(`Like the ${blog} blog`)<br>  }, 500)<br>}<br><br>function share(blog, cb) {<br>  setTimeout(() =&gt; {<br>    cb(`share the ${blog} blog`)<br>  }, 0)<br>}<br><br>Subscribe(&quot;kavya Bhat&quot;, function(name) {<br>  console.log(name)<br>  Like(&quot;Js callbacks&quot;, function(action) {<br>    console.log(action)<br>    share(&quot;Js callbacks&quot;, function(action) {<br>      console.log(action)<br>    })<br>  })<br>})<br><br>console.log(&quot;stop&quot;)</pre><p>output :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/505/1*b3HKz_mS1anvSs8Tan-FAg.png" /></figure><p><em>if share is taken out of the </em><strong><em>subscribe</em></strong><em> Function it will execute first because it has </em><strong><em>0ms in setTimeout </em></strong><em>it does not wait till Like and subscribe is executed or it does not depend on them.</em></p><pre>console.log(&quot;start&quot;)<br><br>function Subscribe(blogername, cb) {<br>  setTimeout(() =&gt; {<br>    cb(`Follow ${blogername} for Frontend content`)<br>  }, 1000)<br>}<br><br>function Like(blog, cb) {<br>  setTimeout(() =&gt; {<br>    cb(`Like the ${blog} blog`)<br>  }, 500)<br>}<br><br>function share(video, cb) {<br>  setTimeout(() =&gt; {<br>    cb(`share the ${video} blog`)<br>  }, 0)<br>}<br><br>Subscribe(&quot;kavya Bhat&quot;, function(name) {<br>  console.log(name)<br>  Like(&quot;Js callbacks&quot;, function(action) {<br>    console.log(action)<br>  })<br>})<br><br>share(&quot;Js callbacks&quot;, function(action) {<br>  console.log(action)<br>})<br><br>console.log(&quot;stop&quot;)</pre><p>output:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/547/1*zfE5D7nXCKJpdvwTgUVkWg.png" /></figure><p><em>we can see there are lot of callbacks one inside the other this type of structure is complex and is known as </em><strong><em>Callback Hell </em></strong><em>to solve this we have</em><strong><em> Promises </em></strong><em>in Java Script </em>.</p><p><strong>Callback Hell</strong>: Callback Hell is essentially nested callbacks stacked below one another forming a pyramid structure. Every callback depends/waits for the previous callback, thereby making a pyramid structure that affects the readability and maintainability of the code.</p><blockquote><strong>Promises</strong></blockquote><p><em>promise is an object that represents the eventual completion or failure of an asynchronous operation.</em></p><p><em>Promises provide a way to handle asynchronous code more cleanly and avoid the callback hell.</em></p><p><strong><em>3 states in Promise</em></strong></p><ol><li><strong><em>Pending:</em></strong><em> The initial state. The promise is neither fulfilled nor rejected.</em></li><li><strong><em>Fulfilled:</em></strong><em> The operation completed successfully, and the promise has a resulting value.</em></li><li><strong><em>Rejected: </em></strong><em>The operation failed, and the promise has a reason for the failure.</em></li></ol><pre>console.log(&quot;start&quot;);<br>let MyPromise = new Promise((resolve, reject) =&gt; {<br>  setTimeout(() =&gt; {<br>    const result = true;<br>    result ? resolve(&quot;Resolved!!!&quot;) : reject(new Error(&quot;Error Please Check&quot;));<br>  }, 1000);<br>});<br>console.log(MyPromise);<br>MyPromise.then((res) =&gt; console.log(res)).catch((err) =&gt; console.log(err));<br>console.log(&quot;stop&quot;);</pre><p>when result is <strong>true</strong> promise will be in <strong>pending</strong> state and once <strong>resolved </strong>it will be in <strong>fulfilled</strong> state .</p><p>output:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/382/1*YeMav2Wdy4jRNhhx0WZvCQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/471/1*dtx3LRTPa6TR3kHhsPJa_Q.png" /></figure><pre>console.log(&quot;start&quot;);<br>let MyPromise = new Promise((resolve, reject) =&gt; {<br>  setTimeout(() =&gt; {<br>    const result = false;<br>    result ? resolve(&quot;Resolved!!!&quot;) : reject(new Error(&quot;Error Please Check&quot;));<br>  }, 2000);<br>});<br>console.log(MyPromise);<br>MyPromise.then((res) =&gt; console.log(res)).catch((err) =&gt; console.log(err));<br>console.log(&quot;stop&quot;);</pre><p>when result is <strong>false </strong>promise will be in <strong>pending</strong> state and once <strong>rejected</strong> it will be in <strong>rejected</strong> state .</p><p>output:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/415/1*-XILxrMV6U7YFpUbJfJ3zg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*RDYcLT5EmK-77e9O3L-CGA.png" /></figure><p>now lets use the same example that we used for callbacks to understand the <strong>Promise chaining !</strong></p><p>here we are trying to resolve promise in all the functions and we are chaining with .then() which returns the next promise that needs to be chained it is very important to return the promise that needs to be chained and logs the response.</p><pre>console.log(&quot;start&quot;)<br><br>function Subscribe(blogername) {<br>  return new Promise((resolve) =&gt; {<br>    setTimeout(() =&gt; {<br>      resolve(`Follow ${blogername} for Frontend content`)<br>    }, 1000)<br>  })<br>}<br><br>function Like(blog) {<br>  return new Promise((resolve) =&gt; {<br>    setTimeout(() =&gt; {<br>      resolve(`Like the ${blog} blog`)<br>    }, 500)<br>  })<br>}<br><br>function share(blog) {<br>  return new Promise((resolve) =&gt; {<br>    setTimeout(() =&gt; {<br>      resolve(`share the ${blog} blog`)<br>    }, 0)<br>  })<br>}<br><br>Subscribe(&quot;kavya Bhat&quot;)<br>  .then(<br>    (res) =&gt; {<br>      console.log(res)<br>      return Like(&quot;Js callbacks&quot;);<br>    }<br>  ).then(<br>    (res) =&gt; {<br>      console.log(res)<br>      return share(&quot;Js callbacks&quot;);<br>    }<br>  ).then(<br>    (res) =&gt; {<br>      console.log(res)<br>    }<br>  ).catch(err=&gt;console.log(err))<br><br>console.log(&quot;stop&quot;)</pre><p>output:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/591/1*wNrqRs6VJtcgQzp-dni7HQ.png" /></figure><p><strong>Promise combinators</strong></p><p>Promise combinators are higher-order functions or methods that operate on multiple promises, allowing you to combine, transform, or handle groups of promises in a more convenient and controlled way.</p><ol><li><strong><em>Promise.all</em></strong></li></ol><p>takes an iterable (usually an array) of promises and returns a new promise that fulfills with an array of all fulfilled values when all the input promises have fulfilled. If any of the promises in the iterable reject, the returned promise is rejected with the reason of the first rejected promise.</p><pre>console.log(&quot;start&quot;)<br><br>function Subscribe(blogername) {<br>  return new Promise((resolve) =&gt; {<br>    setTimeout(() =&gt; {<br>      resolve(`Follow ${blogername} for Frontend content`)<br>    }, 1000)<br>  })<br>}<br><br>function Like(blog) {<br>  return new Promise((resolve) =&gt; {<br>    setTimeout(() =&gt; {<br>      resolve(`Like the ${blog} blog`)<br>    }, 500)<br>  })<br>}<br><br>function share(blog) {<br>  return new Promise((resolve) =&gt; {<br>    setTimeout(() =&gt; {<br>      resolve(`share the ${blog} blog`)<br>    }, 0)<br>  })<br>}<br><br>Promise.all([<br>  Subscribe(&quot;kavya Bhat&quot;),<br>  Like(&quot;Js callbacks&quot;),<br>  share(&quot;Js callbacks&quot;)<br>]).then((res) =&gt; console.log(res))<br>  .catch((err) =&gt; console.log(&quot;Promise Failed&quot;, err))<br><br>console.log(&quot;stop&quot;)</pre><p>output:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jiymYi0OWd_wtLmfZwd9xA.png" /></figure><p>if any one of the promise fails it throws error and other promises are also not returned</p><pre>console.log(&quot;start&quot;)<br><br>function Subscribe(blogername) {<br>  return new Promise((resolve) =&gt; {<br>    setTimeout(() =&gt; {<br>      resolve(`Follow ${blogername} for Frontend content`)<br>    }, 1000)<br>  })<br>}<br><br>function Like(blog) {<br>  return new Promise((resolve,reject) =&gt; {<br>    setTimeout(() =&gt; {<br>      reject(`Like the ${blog} blog`)<br>    }, 500)<br>  })<br>}<br><br>function share(blog) {<br>  return new Promise((resolve) =&gt; {<br>    setTimeout(() =&gt; {<br>      resolve(`share the ${blog} blog`)<br>    }, 0)<br>  })<br>}<br><br>Promise.all([<br>  Subscribe(&quot;kavya Bhat&quot;),<br>  Like(&quot;Js callbacks&quot;),<br>  share(&quot;Js callbacks&quot;)<br>]).then((res) =&gt; console.log(res))<br>  .catch((err) =&gt; console.log(new Error(`Promise Failed --&gt; ${err}`)))<br><br>console.log(&quot;stop&quot;)</pre><p>output:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*j778a44OcNrhvwCiD1kG_A.png" /></figure><p><strong><em>2. Promise.race</em></strong></p><p>takes an iterable of promises and returns a new promise that settles (fulfills or rejects) with the result of the first promise in the iterable to settle.</p><pre>console.log(&quot;start&quot;)<br><br>function Subscribe(blogername) {<br>  return new Promise((resolve) =&gt; {<br>    setTimeout(() =&gt; {<br>      resolve(`Follow ${blogername} for Frontend content`)<br>    }, 1000)<br>  })<br>}<br><br>function Like(blog) {<br>  return new Promise((resolve,reject) =&gt; {<br>    setTimeout(() =&gt; {<br>      resolve(`Like the ${blog} blog`)<br>    }, 500)<br>  })<br>}<br><br>function share(blog) {<br>  return new Promise((resolve) =&gt; {<br>    setTimeout(() =&gt; {<br>      resolve(`share the ${blog} blog`)<br>    }, 0)<br>  })<br>}<br><br>Promise.race([<br>  Subscribe(&quot;kavya Bhat&quot;),<br>  Like(&quot;Js callbacks&quot;),<br>  share(&quot;Js callbacks&quot;)<br>]).then((res) =&gt; console.log(res))<br>  .catch((err) =&gt; console.log(new Error(`Promise Failed --&gt; ${err}`)))<br><br>console.log(&quot;stop&quot;)</pre><p>output:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kmlI1SmxED23Toxu4EVKNQ.png" /></figure><p><strong><em>3. Promise.allStelled</em></strong></p><p>is similar to promise.all, but it waits for all promises to settle (fulfill or reject), and the returned promise is fulfilled with an array of objects representing the outcome of each promise.(it works exactly like promise.all but return other promises)</p><pre>console.log(&quot;start&quot;)<br><br>function Subscribe(blogername) {<br>  return new Promise((resolve) =&gt; {<br>    setTimeout(() =&gt; {<br>      resolve(`Follow ${blogername} for Frontend content`)<br>    }, 1000)<br>  })<br>}<br><br>function Like(blog) {<br>  return new Promise((resolve,reject) =&gt; {<br>    setTimeout(() =&gt; {<br>      reject(`Like the ${blog} blog`)<br>    }, 500)<br>  })<br>}<br><br>function share(blog) {<br>  return new Promise((resolve) =&gt; {<br>    setTimeout(() =&gt; {<br>      resolve(`share the ${blog} blog`)<br>    }, 0)<br>  })<br>}<br><br>Promise.allSettled([<br>  Subscribe(&quot;kavya Bhat&quot;),<br>  Like(&quot;Js callbacks&quot;),<br>  share(&quot;Js callbacks&quot;)<br>]).then((res) =&gt; console.log(res))<br>  .catch((err) =&gt; console.log(new Error(`Promise Failed --&gt; ${err}`)))<br><br>console.log(&quot;stop&quot;)</pre><p>output:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/825/1*nEbwMM0beaigypoAzzKSHg.png" /></figure><p><strong><em>4. Promise.any</em></strong></p><p>takes an iterable of promises and returns a new promise that fulfills with the value of the first fulfilled promise in the iterable. If all promises are rejected, it is rejected with an Error containing all rejection reasons.(it is exactly like Promise.race but it only returns 1st resolved promise and ignore rejected once)</p><pre>console.log(&quot;start&quot;)<br><br>function Subscribe(blogername) {<br>  return new Promise((resolve) =&gt; {<br>    setTimeout(() =&gt; {<br>      resolve(`Follow ${blogername} for Frontend content`)<br>    }, 1000)<br>  })<br>}<br><br>function Like(blog) {<br>  return new Promise((resolve,reject) =&gt; {<br>    setTimeout(() =&gt; {<br>      reject(`Like the ${blog} blog`)<br>    }, 500)<br>  })<br>}<br><br>function share(blog) {<br>  return new Promise((resolve,reject) =&gt; {<br>    setTimeout(() =&gt; {<br>      reject(`share the ${blog} blog`)<br>    }, 0)<br>  })<br>}<br><br>Promise.any([<br>  Subscribe(&quot;kavya Bhat&quot;),<br>  Like(&quot;Js callbacks&quot;),<br>  share(&quot;Js callbacks&quot;)<br>]).then((res) =&gt; console.log(res))<br>  .catch((err) =&gt; console.log(new Error(`Promise Failed --&gt; ${err}`)))<br><br>console.log(&quot;stop&quot;)</pre><p>output:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1009/1*COIG95rbt0OWDdB3XPTrcQ.png" /></figure><p>what if all the Promises are rejected ? it then throws the error</p><pre>console.log(&quot;start&quot;)<br><br>function Subscribe(blogername) {<br>  return new Promise((resolve,reject) =&gt; {<br>    setTimeout(() =&gt; {<br>      reject(`Follow ${blogername} for Frontend content`)<br>    }, 1000)<br>  })<br>}<br><br>function Like(blog) {<br>  return new Promise((resolve,reject) =&gt; {<br>    setTimeout(() =&gt; {<br>      reject(`Like the ${blog} blog`)<br>    }, 500)<br>  })<br>}<br><br>function share(blog) {<br>  return new Promise((resolve,reject) =&gt; {<br>    setTimeout(() =&gt; {<br>      reject(`share the ${blog} blog`)<br>    }, 0)<br>  })<br>}<br><br>Promise.any([<br>  Subscribe(&quot;kavya Bhat&quot;),<br>  Like(&quot;Js callbacks&quot;),<br>  share(&quot;Js callbacks&quot;)<br>]).then((res) =&gt; console.log(res))<br>  .catch((err) =&gt; console.log(new Error(`Promise Failed --&gt; ${err}`)))<br><br>console.log(&quot;stop&quot;)</pre><p>output:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HNi0HuVjYiJoJrBYlIhFBQ.png" /></figure><blockquote><strong>Async/await</strong></blockquote><p><strong>async Function:</strong></p><p>A function declared with the <strong>async </strong>keyword becomes an asynchronous function.</p><pre>async function myAsyncFunction() {<br>    // Asynchronous code<br>}</pre><p><strong>await Operator:</strong></p><p>Used inside an asynchronous function to pause its execution until the Promise is settled (resolved or rejected). used with functions that return Promises.</p><pre>function someAsyncOperation() {<br>    return new Promise((resolve, reject) =&gt; {<br>        // Asynchronous operation, then resolve or reject<br>    });<br>}<br><br>async function myAsyncFunction() {<br>    let result = await someAsyncOperation();<br>    // Continue with the code after the awaited operation is complete<br>}</pre><p>async and await are often used to write asynchronous code in a more readable and synchronous-like manner, making it easier to reason about.</p><p><strong>try and catch</strong></p><p>If an exception occurs within the try block, the control is passed to the catch block. try and catch blocks are used for error handling.</p><pre>try {<br>    // Code that might throw an exception<br>} catch (error) {<br>    // Code to handle the exception<br>}</pre><p>when All the promise resolve.</p><pre>console.log(&quot;start&quot;)<br><br>function Subscribe(blogername) {<br>  return new Promise((resolve, reject) =&gt; {<br>    setTimeout(() =&gt; {<br>      resolve(`Follow ${blogername} for Frontend content`)<br>    }, 1000)<br>  })<br>}<br><br>function Like(blog) {<br>  return new Promise((resolve, reject) =&gt; {<br>    setTimeout(() =&gt; {<br>      resolve(`Like the ${blog} blog`)<br>    }, 500)<br>  })<br>}<br><br>function share(blog) {<br>  return new Promise((resolve, reject) =&gt; {<br>    setTimeout(() =&gt; {<br>      resolve(`share the ${blog} blog`)<br>    }, 0)<br>  })<br>}<br><br>const result = async () =&gt; {<br>  try {<br>    const message1 = await Subscribe(&quot;kavya Bhat&quot;);<br>    const message2 = await Like(&quot;Js callbacks&quot;);<br>    const message3 = await share(&quot;Js callbacks&quot;);<br>    console.log(message1, message2, message3)<br>  }<br>  catch (error) {<br>    console.log(&quot;Promise Failed &quot;, error)<br>  }<br>}<br>result()<br>console.log(&quot;stop&quot;)<br></pre><p>output:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mmGmMkq6FAnrAypt0UH1sQ.png" /></figure><p>if there is an error in any or rejected</p><pre>console.log(&quot;start&quot;)<br><br>function Subscribe(blogername) {<br>  return new Promise((resolve, reject) =&gt; {<br>    setTimeout(() =&gt; {<br>      resolve(`Follow ${blogername} for Frontend content`)<br>    }, 1000)<br>  })<br>}<br><br>function Like(blog) {<br>  return new Promise((resolve, reject) =&gt; {<br>    setTimeout(() =&gt; {<br>      reject(`Like the ${blog} blog`)<br>    }, 500)<br>  })<br>}<br><br>function share(blog) {<br>  return new Promise((resolve, reject) =&gt; {<br>    setTimeout(() =&gt; {<br>      resolve(`share the ${blog} blog`)<br>    }, 0)<br>  })<br>}<br><br>const result = async () =&gt; {<br>  try {<br>    const message1 = await Subscribe(&quot;kavya Bhat&quot;);<br>    const message2 = await Like(&quot;Js callbacks&quot;);<br>    const message3 = await share(&quot;Js callbacks&quot;);<br>    console.log(message1, message2, message3)<br>  }<br>  catch (error) {<br>    console.log(&quot;Promise Failed &quot;, error)<br>  }<br>}<br>result()<br>console.log(&quot;stop&quot;)</pre><p>output:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0OCNk7Rmthozcwr9CABkfg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/250/1*5q-a2IdIqmjM3quusv147A.gif" /></figure><h3>Stackademic</h3><p><em>Thank you for reading until the end. Before you go:</em></p><ul><li><em>Please consider </em><strong><em>clapping</em></strong><em> and </em><strong><em>following</em></strong><em> the writer! 👏</em></li><li><em>Follow us on </em><a href="https://twitter.com/stackademichq"><strong><em>Twitter(X)</em></strong></a><em>, </em><a href="https://www.linkedin.com/company/stackademic"><strong><em>LinkedIn</em></strong></a><em>, and </em><a href="https://www.youtube.com/c/stackademic"><strong><em>YouTube</em></strong></a><strong><em>.</em></strong></li><li><em>Visit </em><a href="http://stackademic.com/"><strong><em>Stackademic.com</em></strong></a><em> to find out more about how we are democratizing free programming education around the world.</em></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=538ca66d1fe5" width="1" height="1" alt=""><hr><p><a href="https://blog.stackademic.com/unlocking-javascripts-asynchronous-potential-callbacks-promises-and-%EF%B8%8Fasync-await-538ca66d1fe5">Unlocking JavaScript’s Asynchronous Potential : Callbacks 🔄, Promises 🤝 and ⚡️Async/Await 🚀⌛</a> was originally published in <a href="https://blog.stackademic.com/">Stackademic</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Top Strategies for Optimizing Your React App for Peak Performance]]></title>
            <link>https://blog.stackademic.com/top-strategies-for-optimizing-your-react-app-for-peak-performance-ab40217f9a9e?source=rss-401590a4d40a------2</link>
            <guid isPermaLink="false">https://medium.com/p/ab40217f9a9e</guid>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[react]]></category>
            <category><![CDATA[optimization]]></category>
            <category><![CDATA[performance]]></category>
            <dc:creator><![CDATA[Kavyabhat]]></dc:creator>
            <pubDate>Sun, 01 Oct 2023 05:33:03 GMT</pubDate>
            <atom:updated>2023-10-02T01:04:22.750Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/481/1*rGfm1VPIKn8fcr8jxKlWcA.png" /></figure><blockquote><strong>Single Responsibility Principle</strong></blockquote><p>The Single Responsibility Principle (SRP) in React components states that a component should have a single responsibility or purpose. This principle helps in maintaining clean, modular, and maintainable code by ensuring that each component focuses on a specific functionality or task, making it easier to understand, test, and update.</p><p><strong><em>Separating rendering and data logic</em></strong>: Keep rendering and data fetching/manipulation separate in different components or functions.(custom hooks).</p><p><strong><em>Reusable components: </em></strong>Create small, focused components that can be easily reused in different parts of your application.</p><p><strong><em>Testability:</em></strong> Components with a single responsibility are easier to test and maintain.</p><p><strong><em>Maintainability:</em></strong> Easier to understand, update, and refactor when each component has a clear purpose.</p><p><strong><em>Scalability:</em></strong> Makes it easier to scale and extend your application by isolating specific functionality in separate components.</p><blockquote><strong>Chunking | Code Splitting | Dynamic Bundling | Lazy Loading | on demand Loading</strong></blockquote><p>React Lazy and Suspense is a powerful tool to help you achieve the optimization we require. It works by dynamically getting components when they are required by your App rather than adding them to the main bundle that will be pulled by the browser at the very beginning.</p><p>App can be divided in such a way that bundle are broken in to small bundles with specific use and can be called only when requested, we can see only one js file in our dist folder where 1000 of components are there in one file in complex Apps which can be divided in to small bundles say with 100 components in each bundle.</p><p>We import the lazy function from React to create a dynamic import of the LazyComponent.</p><p>We wrap the lazy-loaded component (LazyComponent) with a Suspense component, providing a fallback prop. The fallback prop defines what to render while the component is being loaded.</p><p>When the LazyComponent is needed (e.g., when the user navigates to a route that requires it), it will be loaded lazily, and the loading fallback will be displayed until it&#39;s ready.</p><pre>import React, { lazy, Suspense } from &#39;react&#39;;<br><br>//dynamic Import <br>const LazyComponent = lazy(() =&gt; import(&#39;./LazyComponent&#39;));<br><br>function App() {<br>  return (<br>    &lt;div&gt;<br>      &lt;h1&gt;Lazy Loading Example&lt;/h1&gt;<br>      {/* Wrap the lazy-loaded component with Suspense */}<br>      &lt;Suspense fallback={&lt;div&gt;Loading...&lt;/div&gt;}&gt;<br>        &lt;LazyComponent /&gt;<br>      &lt;/Suspense&gt;<br>    &lt;/div&gt;<br>  );<br>}<br><br>export default App;</pre><blockquote><strong>useMemo Hook</strong></blockquote><p>useMemo is a React hook used to memoize (cache) the result of expensive computations or function calls. It can improve the performance of a website by preventing unnecessary recalculations and rendering when the inputs to a component or function haven&#39;t changed or depend on props that haven’t changed. This can lead to faster rendering and a more responsive user interface, especially in complex components or scenarios where calculations are intensive.</p><p>We have a state variable number and a computed value squaredNumber.</p><p>We use the useMemo hook to memoize the calculation of squaredNumber. It takes two arguments: a function that computes the value and an array of dependencies ([number] in this case).</p><p>The computed value, squaredNumber, is only recalculated when the number state changes. If you increment the number, only the squared value will be recalculated, not the entire component.</p><pre>import React, { useState, useMemo } from &#39;react&#39;;<br><br>function App() {<br>  const [number, setNumber] = useState(0);<br>  <br>  // Calculate the square of &#39;number&#39; only when &#39;number&#39; changes<br>  const squaredNumber = useMemo(() =&gt; {<br>    return number * number;<br>  }, [number]);<br><br>  return (<br>    &lt;div&gt;<br>      &lt;h1&gt;useMemo Example&lt;/h1&gt;<br>      &lt;p&gt;Number: {number}&lt;/p&gt;<br>      &lt;p&gt;Squared Number: {squaredNumber}&lt;/p&gt;<br>      &lt;button onClick={() =&gt; setNumber(number + 1)}&gt;Increment&lt;/button&gt;<br>    &lt;/div&gt;<br>  );<br>}<br><br>export default App;</pre><blockquote><strong>Removing Redundant Api calls</strong></blockquote><p>Removing redundant API calls improves performance by reducing unnecessary network requests and server processing, resulting in faster page load times and a more efficient use of resources. remove redundant API calls by implementing caching, debouncing, throttling, and optimizing data fetching to minimize unnecessary requests to the server.</p><p><strong>Debouncing:</strong> Control how often API calls are made by delaying calls during rapid user interactions.</p><p><strong>Throttling:</strong> Limit the rate of API requests to prevent overloading the server.</p><p><strong>State Management: </strong>Use centralized state management to share data between components and avoid multiple API calls.</p><p><strong>Conditional Fetching:</strong> Fetch data based on specific conditions, preventing unnecessary calls.</p><p><strong>Caching:</strong> Store API responses locally to avoid redundant network requests.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/250/1*5q-a2IdIqmjM3quusv147A.gif" /></figure><h3>Stackademic</h3><p><em>Thank you for reading until the end. Before you go:</em></p><ul><li><em>Please consider </em><strong><em>clapping</em></strong><em> and </em><strong><em>following</em></strong><em> the writer! 👏</em></li><li><em>Follow us on </em><a href="https://twitter.com/stackademichq"><strong><em>Twitter(X)</em></strong></a><em>, </em><a href="https://www.linkedin.com/company/stackademic"><strong><em>LinkedIn</em></strong></a><em>, and </em><a href="https://www.youtube.com/c/stackademic"><strong><em>YouTube</em></strong></a><strong><em>.</em></strong></li><li><em>Visit </em><a href="http://stackademic.com/"><strong><em>Stackademic.com</em></strong></a><em> to find out more about how we are democratizing free programming education around the world.</em></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ab40217f9a9e" width="1" height="1" alt=""><hr><p><a href="https://blog.stackademic.com/top-strategies-for-optimizing-your-react-app-for-peak-performance-ab40217f9a9e">Top Strategies for Optimizing Your React App for Peak Performance</a> was originally published in <a href="https://blog.stackademic.com/">Stackademic</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[React Project with npm, npx, and Bundlers: Turning Your Ideas into Dynamic Web Applications]]></title>
            <link>https://blog.stackademic.com/react-project-with-npm-npx-and-bundlers-turning-your-ideas-into-dynamic-web-fb02df7a252?source=rss-401590a4d40a------2</link>
            <guid isPermaLink="false">https://medium.com/p/fb02df7a252</guid>
            <category><![CDATA[react]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[reactjs]]></category>
            <category><![CDATA[parcel-bundler]]></category>
            <category><![CDATA[web-development]]></category>
            <dc:creator><![CDATA[Kavyabhat]]></dc:creator>
            <pubDate>Tue, 12 Sep 2023 05:20:35 GMT</pubDate>
            <atom:updated>2023-09-13T05:42:39.506Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/372/1*UokH9eehCfk8sYBB9zRgSg.png" /></figure><blockquote><strong>Enjoy the Ride</strong>: “Above all, enjoy the process. Building with React is not just about the destination; it’s about the journey of creating something amazing.”</blockquote><p>In this article, let&#39;s see some topics in the form of questions and answers covering npm, bundlers&#39; usage, what is pushed into a production code, and more! For more explanation, do check out the Namaste React ❤️series by <a href="https://medium.com/u/f5887269d66e">Akshay Saini</a>.</p><h4><strong>1. What is npm?</strong></h4><p>It is a widely used package manager for JavaScript programming language.</p><p>It allows developers to easily install, manage, and share libraries and dependencies (packages) needed for their web and Node.js applications.</p><h4><strong>2. What is Parcel or Webpack and why do we use it?</strong></h4><p>Parcel and Webpack are both popular JavaScript bundlers used in web development to optimize and package assets like JavaScript, CSS, and images for production-ready web applications.</p><ul><li>They help manage dependencies and assets in modern web development.</li><li>They allow you to bundle and optimize your code for production.</li><li>They enable the use of modern JavaScript features that might not be supported in all browsers by default.</li><li>They facilitate a modular approach to code organization, improving the maintainability and scalability of projects.</li></ul><h4><strong>3. What is .parcel-cache?</strong></h4><p>The .parcel-cache directory is a folder created by the Parcel bundler in your project’s root directory. It is used to cache and store intermediate build artifacts, dependencies, and compiled assets to improve build performance. Parcel uses this cache to avoid redundant work during subsequent builds, making the development process faster and more efficient.</p><p>It helps speed up the bundling process by reusing previously processed data, especially for larger projects or when dealing with complex dependencies.</p><h4><strong>4. What is npx?</strong></h4><p>A command-line tool that comes with Node.js and is used to execute packages from the npm registry</p><h4><strong>5. What is the diff between dependencies and devdependencies?</strong></h4><p>Dependencies:</p><ul><li>These are the packages that are required for your application to run in a production environment.</li><li>They include libraries and frameworks that your application relies on to function properly.</li><li>Examples include web frameworks, utility libraries, database connectors, etc.</li><li>When someone installs your application (typically a user or another developer), these packages will be installed as well.</li></ul><p>DevDependencies:</p><ul><li>These are packages that are only needed for development and testing purposes.</li><li>They are not required for the application to function in a production environment.</li><li>Examples include testing frameworks, build tools, linters, etc.</li><li>When someone is working on the project, they would need these packages to help with development, but they are not included when the project is deployed or distributed.</li></ul><h4><strong>6. What is Tree shaking?</strong></h4><p>It refers to the process of eliminating or “shaking off” dead or unused code (JavaScript modules or functions) from the final bundled output.</p><p>The goal of tree shaking is to reduce the size of the bundled JavaScript file, making it more efficient and faster to load in a web browser.</p><h4><strong>7. What is hot module replacement?</strong></h4><p>It allows developers to see changes made to their code in real-time without having to manually refresh the entire web page or restart the development server.</p><h4><strong>8. List down 5 super power of parcel describe?</strong></h4><p><strong>Bundling:</strong></p><p>Parcel bundles your project’s JavaScript, CSS, HTML, and other assets into optimized and production-ready files. It automatically handles dependencies and ensures that your application is efficiently packaged for deployment.</p><p><strong>Development Server:</strong></p><p>Parcel comes with a built-in development server that makes it easy to preview your project during development. It supports features like auto-reloading when you make code changes.</p><p><strong>Zero Configuration:</strong></p><p>One of Parcel’s notable features is its zero-configuration setup.</p><p>You can start using Parcel without complex configuration files, allowing you to focus on writing code instead of building configurations.</p><p><strong>Support for Multiple File Types:</strong></p><p>Parcel supports various file types out of the box, including JavaScript (ES6+), CSS (Sass, Less), HTML, and more. It can even handle assets like images and fonts, optimizing them as needed.</p><p><strong>Optimizations:</strong></p><p>Parcel automatically performs optimizations like minification and code splitting to reduce the size of your assets and improve load times.</p><h4><strong>9. What is .gitignore? What we should add or not add to it?</strong></h4><p>.gitignore is a configuration file used in Git repositories to specify which files and directories should be ignored by Git when tracking changes.</p><p>By adding files or patterns to the .gitignore file, you can prevent Git from including them in version control, which is particularly useful for files that are generated during the development process, contain sensitive information, or are simply not relevant to the project’s history.</p><p>Here are some common things to add to a .gitignore file:</p><p><strong>Node Modules:</strong></p><p>Ignore the node_modules directory, which contains dependencies installed by npm or Yarn.</p><p>These are typically large and can be easily regenerated by running package installation commands.</p><pre>/node_modules</pre><p><strong>Build Artifacts:</strong></p><p>Ignore files and directories generated during the build process, such as compiled code, transpiled code, or minified files.</p><pre>/dist<br>/build<br>/out</pre><p><strong>Temporary Files:</strong></p><p>Ignore files generated by text editors or IDEs, like .DS_Store on macOS, or temporary backup files.</p><pre>.DS_Store<br>*~</pre><p><strong>Environment Files:</strong></p><p>Ignore environment-specific configuration files, especially if they contain sensitive information like API keys or passwords.</p><pre>.env<br>.env.local</pre><p><strong>Logs and Debug Output:</strong></p><p>Ignore log files, debug output, or error logs generated during development.</p><pre>/logs<br>*.log</pre><p><strong>User-Specific Files:</strong></p><p>Ignore files or directories that are specific to individual developers or their development environments.</p><pre>/user-settings</pre><p><strong>Dependency Lock Files:</strong></p><p>Depending on your project setup, you might want to ignore lock files generated by package managers like package-lock.json or yarn.lock.</p><pre>/package-lock.json<br>/yarn.lock</pre><p><strong>IDE and Editor Files:</strong></p><p>Ignore configuration files and directories specific to your IDE or code editor.</p><pre>.vscode/<br>.idea/</pre><h4><strong>10. What is the diff between package.json and package.lock.json?</strong></h4><p>package.json:</p><p>This file contains metadata about your project and its dependencies.</p><p>It specifies which packages your project depends on and their versions.</p><p>It’s meant for human-readable information and high-level project configuration.</p><p>Developers typically edit this file directly to add or update dependencies.</p><p>It doesn’t lock the exact versions of dependencies, so it allows for some flexibility in versions.</p><p>package-lock.json:</p><p>This file is automatically generated by npm (Node Package Manager) and is used to lock down the specific versions of dependencies.</p><p>It ensures that everyone working on the project uses the exact same versions of packages.</p><p>It’s primarily used to guarantee reproducibility and consistency when building and running the project across different environments or by different developers.</p><p>Developers generally don’t edit this file manually.</p><p>In summary, package.json is for high-level project configuration and specifying dependencies, while package-lock.json is for ensuring that everyone working on the project uses the same versions of those dependencies, making it a critical tool for maintaining consistency in a Node.js project.</p><h4><strong>11. What is node_modules? Is it a good idea to push that on to git?</strong></h4><p>It’s best practice to exclude the node_modules directory from version control and rely on your project’s package.json and lock file (package-lock.json or yarn.lock) to manage and recreate the dependencies when needed.</p><p>This approach promotes a more efficient and secure development workflow.</p><h4><strong>12. What is dist folder?</strong></h4><p>A “dist” folder, short for “distribution,” is a directory typically found in software development projects. It contains the files and assets that are intended for distribution or deployment in a production environment. These files are often optimized, compiled, or bundled versions of the source code and assets.</p><p>The “dist” folder typically includes:</p><ul><li>Minified or compiled code files (e.g., JavaScript, CSS) to reduce file size and improve performance.</li><li>Production-ready HTML files.</li><li>Images, fonts, or other static assets required for the application to run.</li><li>Configuration files and dependencies required for the deployed application.</li></ul><p>Developers create the “dist” folder as part of the build process to prepare the application for deployment. It helps separate the development and production environments, ensuring that the deployed application is efficient and optimized for end-users.</p><h4><strong>13. What is browserLists?</strong></h4><p>Browserslist is a configuration file or setting used in web development tools like Autoprefixer, Babel, and stylelint to specify which web browsers and their versions you want to support when writing CSS or JavaScript code. It allows you to define a list of target browsers for your project, and tools that use browserslist will automatically generate code that is compatible with those specified browsers, including adding necessary vendor prefixes and transpiling JavaScript features.</p><p>For example, by setting a browserslist configuration to support the “last 2 versions” of major browsers, your development tools can ensure that your CSS and JavaScript are compatible with recent browser releases, helping to maintain cross-browser compatibility for your web applications.</p><h4><strong>14. Diff bundlers?</strong></h4><p><strong>Webpack:</strong></p><p>Purpose: Highly configurable bundler used for managing dependencies, optimizing assets, and preparing them for production.</p><p>Key Features: Supports various loaders and plugins for tasks like transpilation, minification, code splitting, and more.</p><p>Use Cases: Well-suited for complex projects with advanced configuration needs.</p><p><strong>Parcel:</strong></p><p>Purpose: Zero-config bundler designed for simplicity and ease of use.</p><p>Key Features: Requires minimal configuration, automatically handles dependencies, and provides a built-in development server.</p><p>Use Cases: Great for quick prototyping, small to medium-sized projects, or when you prefer a minimal setup.</p><p><strong>Rollup:</strong></p><p>Purpose: JavaScript module bundler optimized for libraries and packages.</p><p>Key Features: Focuses on producing smaller, more efficient bundles, making it ideal for publishing libraries.</p><p>Use Cases: Best suited for building libraries or packages meant to be consumed by other developers.</p><p><strong>Browserify:</strong></p><p>Purpose: Bundles Node.js-style modules for use in the browser.</p><p>Key Features: Translates Node.js-style require() calls to browser-compatible code.</p><p>Use Cases: Initially popular for adapting server-side code for client-side use, but has been largely superseded by Webpack.</p><p><strong>FuseBox:</strong></p><p>Purpose: Fast, efficient bundler with features like JIT (Just-In-Time) compilation.</p><p>Key Features: Emphasizes speed and performance, includes a development server, and supports a wide range of plugins.</p><p>Use Cases: Well-suited for projects where fast build times are a critical consideration.</p><p><strong>Brunch:</strong></p><p>Purpose: An opinionated, simple, and fast bundler with a focus on configurability.</p><p>Key Features: Minimal configuration required, supports a wide range of plugins, and provides a built-in development server.</p><p>Use Cases: Projects where simplicity and speed of setup are valued.</p><h4><strong>15. ^ and ~</strong></h4><p><strong>^ (caret):</strong></p><p>Allows changes in the minor and patch versions but locks the major version.</p><p>Example: ^1.2.3 allows any version from 1.2.3 up to but not including 2.0.0.</p><p><strong>~ (tilde):</strong></p><p>Allows changes in the patch version but locks the major and minor versions.</p><p>Example: ~1.2.3 allows any version from 1.2.3 up to but not including 1.3.0.</p><h4><strong>16. Script types in html?</strong></h4><p><strong>JavaScript (default):</strong></p><p>&lt;script&gt; tag without a specified type defaults to JavaScript.</p><p>Example: &lt;script&gt;console.log(“Hello, World!”);&lt;/script&gt;</p><p><strong>JavaScript with a specific version:</strong></p><p>You can specify a version of JavaScript using the type attribute, like type=”text/javascript”.</p><p>Example: &lt;script type=”text/javascript”&gt;console.log(“Hello, World!”);&lt;/script&gt;</p><p><strong>Module scripts:</strong></p><p>Introduced in HTML5, module scripts use type=”module”.</p><p>Enables the use of ES6 modules for better code organization and modularity.</p><p>Example: &lt;script type=”module” src=”main.js”&gt;&lt;/script&gt;</p><p>Thank you 😊</p><h3>Stackademic</h3><p><em>Thank you for reading until the end. Before you go:</em></p><ul><li><em>Please consider </em><strong><em>clapping</em></strong><em> and </em><strong><em>following</em></strong><em> the writer! 👏</em></li><li><em>Follow us on </em><a href="https://twitter.com/stackademichq"><strong><em>Twitter(X)</em></strong></a><em>, </em><a href="https://www.linkedin.com/company/stackademic"><strong><em>LinkedIn</em></strong></a><em>, and </em><a href="https://www.youtube.com/c/stackademic"><strong><em>YouTube</em></strong></a><strong><em>.</em></strong></li><li><em>Visit </em><a href="http://stackademic.com/"><strong><em>Stackademic.com</em></strong></a><em> to find out more about how we are democratizing free programming education around the world.</em></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fb02df7a252" width="1" height="1" alt=""><hr><p><a href="https://blog.stackademic.com/react-project-with-npm-npx-and-bundlers-turning-your-ideas-into-dynamic-web-fb02df7a252">React Project with npm, npx, and Bundlers: Turning Your Ideas into Dynamic Web Applications</a> was originally published in <a href="https://blog.stackademic.com/">Stackademic</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[JavaScript Practical Examples]]></title>
            <link>https://blog.stackademic.com/java-script-practical-examples-54f07d0fb136?source=rss-401590a4d40a------2</link>
            <guid isPermaLink="false">https://medium.com/p/54f07d0fb136</guid>
            <category><![CDATA[frontend]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[interview]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[web-development]]></category>
            <dc:creator><![CDATA[Kavyabhat]]></dc:creator>
            <pubDate>Sun, 27 Aug 2023 06:04:03 GMT</pubDate>
            <atom:updated>2023-09-14T03:56:38.345Z</atom:updated>
            <content:encoded><![CDATA[<h3>JavaScript Basic Coding Questions</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/473/1*Xru9itu4DlHgVh0IN1APlg.png" /></figure><p>Hey …</p><p>These are some of the examples for JavaScript concepts which may help during Interview to give the code Example and explain !</p><pre>//Example for Promise<br>//Producer<br>const MyPromise = new Promise((resolve, reject) =&gt; {<br>  var a = true;<br>  return a ? resolve(&quot;Hey Its Resolved&quot;) : reject(&quot;Error&quot;)<br>})<br><br><br>//consumer<br>MyPromise<br>  .then((val) =&gt; console.log(val))<br>  .catch((err) =&gt; console.log(err))<br><br>//closure <br>function outer() {<br>  var count = 0<br><br>  function inner() {<br>    console.log(++count);<br>  }<br>  return inner;<br>}<br><br>let result = outer();<br>result();<br><br>//callback<br>function mainFuunction(callback) {<br>  console.log(&quot;proceessing ...&quot;);<br>  setTimeout(() =&gt; {<br>    return callback();<br>  }, 1000);<br>}<br><br>function callback() {<br>  console.log(&quot;Completed!&quot;);<br>}<br>console.log(mainFuunction(callback));<br><br>//Currying<br>const sum = (a) =&gt; (b) =&gt; (c) =&gt; a + b + c;<br>console.log(sum(1)(2)(3));<br><br>//PureFunctions<br>function Pure(l, b) {<br>  return l * b<br>}<br>console.log(Pure(3, 100));<br><br>//Deepcopy/Shallowcopy<br>//Deepcopy<br><br>var deepa = 10;<br>var deepb = deepa;<br>deepb = 20;<br>console.log(deepa, deepb);<br><br>//shallow<br>var shallowa = [1, 2, 3];<br>var shallowb = shallowa;<br>shallowb.push(7);<br>console.log(shallowa, shallowb);<br><br>//call apply bind<br>//call<br>let person = {<br>  Fname: &#39;kavya&#39;,<br>  Lname: &#39;bhat&#39;<br>}<br><br>function fullName() {<br>  return console.log(this.Fname + &quot; &quot; + this.Lname);<br>}<br><br>fullName.call(person);<br><br>//apply<br>let person1 = {<br>  Fname: &#39;Divya&#39;,<br>  Lname: &#39;Hegde&#39;<br>}<br><br>function fullName1(city1, city2, city3) {<br>  return console.log(this.Fname + &quot; &quot; + this.Lname + &quot; &quot; + city1 + &quot; &quot; + city2 + &quot; &quot; + city3);<br>}<br>var cities = [&#39;Banglore&#39;, &#39;Mumbai&#39;, &#39;Pune&#39;]<br>fullName1.apply(person1, cities);<br><br>//Bind<br>let person3 = {<br>  Fname: &#39;Bhavya&#39;,<br>  Lname: &#39;Joshi&#39;<br>}<br><br>function fullName3() {<br>  return console.log(this.Fname + &quot; &quot; + this.Lname);<br>}<br><br>console.log(fullName3.bind(person3));<br><br>//Foreach map filter reduce <br>//forEach<br>var foreacharr = [1, 2, 3];<br>foreacharr.forEach((ele) =&gt; {<br>  console.log(ele);<br>})<br><br>//map<br>var maparr = [1, 2, 3];<br>let outputmap = maparr.map((ele) =&gt; {<br>  return console.log(ele * 2);<br>})<br>console.log(maparr, outputmap);<br><br>//filter<br>var filterarr = [1, 2, 3, 4, 5, 6];<br>let outputfilter = filterarr.filter((ele) =&gt; {<br>  return (ele % 2 === 0);<br>})<br>console.log(filterarr, outputfilter);<br><br>//reduce<br>var reducearr = [1, 2, 3, 4];<br>let outputreduce = reducearr.reduce((acc, ele) =&gt; {<br>  return ele + acc;<br>}, 0)<br>console.log(outputreduce);</pre><p>Thank you😄</p><h3>Stackademic</h3><p><em>Thank you for reading until the end. Before you go:</em></p><ul><li><em>Please consider </em><strong><em>clapping</em></strong><em> and </em><strong><em>following</em></strong><em> the writer! 👏</em></li><li><em>Follow us on </em><a href="https://twitter.com/stackademichq"><strong><em>Twitter(X)</em></strong></a><em>, </em><a href="https://www.linkedin.com/company/stackademic"><strong><em>LinkedIn</em></strong></a><em>, and </em><a href="https://www.youtube.com/c/stackademic"><strong><em>YouTube</em></strong></a><strong><em>.</em></strong></li><li><em>Visit </em><a href="http://stackademic.com/"><strong><em>Stackademic.com</em></strong></a><em> to find out more about how we are democratizing free programming education around the world.</em></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=54f07d0fb136" width="1" height="1" alt=""><hr><p><a href="https://blog.stackademic.com/java-script-practical-examples-54f07d0fb136">JavaScript Practical Examples</a> was originally published in <a href="https://blog.stackademic.com/">Stackademic</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Elevating Your UI Game with React Fragments]]></title>
            <link>https://blog.stackademic.com/elevating-your-ui-game-with-react-fragments-654483ef1ade?source=rss-401590a4d40a------2</link>
            <guid isPermaLink="false">https://medium.com/p/654483ef1ade</guid>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[react-fragments]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[react]]></category>
            <category><![CDATA[programming]]></category>
            <dc:creator><![CDATA[Kavyabhat]]></dc:creator>
            <pubDate>Mon, 21 Aug 2023 04:56:06 GMT</pubDate>
            <atom:updated>2023-09-13T03:17:18.734Z</atom:updated>
            <content:encoded><![CDATA[<p>In the ever-evolving landscape of web development, React Fragments have emerged as a powerful tool, offering developers new ways to structure and optimize user interfaces. In this blog, we embark on a journey through the world of React Fragments.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/550/1*6ErUq1Bt1ZbFJueW8pJDgQ.png" /></figure><blockquote><strong>React Fragments</strong></blockquote><p>React Fragments, also known as the <strong>&lt;&gt;…&lt;/&gt;</strong> syntax or the <strong>&lt;React.Fragment&gt;…&lt;/React.Fragment&gt;</strong> syntax, are a feature in React that allow you to group multiple elements without introducing an extra parent element into the DOM. In other words, they let you group elements together without adding an unnecessary HTML wrapper element when rendering.</p><blockquote><strong>Here’s why React Fragments are useful:</strong></blockquote><p>1. <strong>Avoid Extra DOM Elements</strong>: In React, when you want to return multiple elements from a component, you generally need to wrap them in a parent element. However, this can lead to unnecessary wrapper elements in the actual DOM, which might affect CSS styling and layout.</p><p>2. <strong>Cleaner Structure</strong>: Using React Fragments keeps your component’s structure cleaner and closer to what you want to render, without needing to insert elements that exist solely for the purpose of grouping.</p><p>3. <strong>Reduced DOM Overhead</strong>: By using Fragments, you can keep the DOM structure more streamlined and reduce the number of nodes, potentially leading to better performance and a smaller memory footprint.</p><p>4. <strong>Flexibility</strong>: Fragments can be used with a map function, allowing you to create lists of elements without introducing additional parent elements for each item.</p><blockquote><strong>Key in React Fragments</strong></blockquote><p>In React, when rendering a list of elements using fragments, it’s important to provide a unique key prop to each element. The key prop helps React identify each element and efficiently update the DOM when changes occur. The key prop should be a stable and unique identifier for each item in the list.</p><p>Here’s why using key is important:</p><p><strong>Efficient Updates</strong>: React uses the key prop to determine which elements have changed, been added, or been removed when updating a list. This helps optimize the updating process and avoid unnecessary re-renders.</p><p><strong>Stable Identity</strong>: Providing a key ensures that React can distinguish between elements, even if their order changes. It helps React maintain a stable identity for each item.</p><p><strong>Avoiding Reconciliation Errors</strong>: Without unique keys, React might have trouble efficiently updating the list, which could lead to errors or inefficient rendering.</p><p><strong>Example usage of key in a list of elements:</strong></p><pre>import React from &#39;react&#39;;<br><br>function ListComponent({ items }) {<br>  return (<br>    &lt;ul&gt;<br>      {items.map((item) =&gt; (<br>        &lt;React.Fragment key={item.id}&gt;<br>          &lt;li&gt;{item.name}&lt;/li&gt;<br>        &lt;/React.Fragment&gt;<br>      ))}<br>    &lt;/ul&gt;<br>  );<br>}<br><br>export default ListComponent;</pre><p>In this example, <strong>item.id</strong> is used as the <strong>key</strong> for each element in the list. If you’re rendering elements without a unique identifier, you might encounter warnings in the console advising you to provide a <strong>key</strong>.</p><p>Remember that the <strong>key</strong> prop is not meant to be accessed within the component; it’s only used by React’s reconciliation algorithm to efficiently manage updates. Always ensure that the <strong>key</strong> values are unique and stable across re-renders.</p><h3>Stackademic</h3><p><em>Thank you for reading until the end. Before you go:</em></p><ul><li><em>Please consider </em><strong><em>clapping</em></strong><em> and </em><strong><em>following</em></strong><em> the writer! 👏</em></li><li><em>Follow us on </em><a href="https://twitter.com/stackademichq"><strong><em>Twitter(X)</em></strong></a><em>, </em><a href="https://www.linkedin.com/company/stackademic"><strong><em>LinkedIn</em></strong></a><em>, and </em><a href="https://www.youtube.com/c/stackademic"><strong><em>YouTube</em></strong></a><strong><em>.</em></strong></li><li><em>Visit </em><a href="http://stackademic.com/"><strong><em>Stackademic.com</em></strong></a><em> to find out more about how we are democratizing free programming education around the world.</em></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=654483ef1ade" width="1" height="1" alt=""><hr><p><a href="https://blog.stackademic.com/elevating-your-ui-game-with-react-fragments-654483ef1ade">Elevating Your UI Game with React Fragments</a> was originally published in <a href="https://blog.stackademic.com/">Stackademic</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[React Lifecycle Methods : A Journey from Class Components to Functional Components]]></title>
            <link>https://blog.stackademic.com/react-lifecycle-methods-a-journey-from-class-components-to-functional-components-68cf2ed3c51b?source=rss-401590a4d40a------2</link>
            <guid isPermaLink="false">https://medium.com/p/68cf2ed3c51b</guid>
            <category><![CDATA[react]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[web-development]]></category>
            <dc:creator><![CDATA[Kavyabhat]]></dc:creator>
            <pubDate>Sun, 20 Aug 2023 06:42:46 GMT</pubDate>
            <atom:updated>2023-09-13T03:17:31.763Z</atom:updated>
            <content:encoded><![CDATA[<h3>React Lifecycle Methods: A Journey from Class Components to Functional Components</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/498/1*M2pjfv4be0IF0w_UqVXSIA.png" /></figure><p>🚀<strong><em>First lets see the Order of all lifecycle methods</em></strong></p><blockquote><strong><em>Mounting Phase:</em></strong></blockquote><ul><li><em>constructor(): Initializes the component&#39;s state and sets up initial values.</em></li><li><em>getDerivedStateFromProps(): Updates state based on incoming props before rendering.</em></li><li><em>render(): Returns JSX to be displayed in the UI.</em></li><li><em>componentDidMount(): Executes after initial render, ideal for side effects like data fetching (Api calls).</em></li></ul><blockquote><strong><em>Updating Phase:</em></strong></blockquote><ul><li><em>getDerivedStateFromProps(): Similar to the mounting phase, updates state based on incoming props.</em></li><li><em>shouldComponentUpdate(): Decides whether the component should re-render, optimizing performance. returns true or false based on updated or not.</em></li><li><em>render(): Updates the UI with new JSX based on changed props or state.</em></li><li><em>getSnapshotBeforeUpdate(): Captures information from the DOM before it updates. This method is called right before the changes from the Virtual DOM are reflected in the actual DOM. It can be used to capture information before the update.</em></li><li><em>componentDidUpdate(): Executes after the component has re-rendered, useful for post-update side effects.</em></li></ul><blockquote><strong><em>Unmounting Phase:</em></strong></blockquote><ul><li><em>componentWillUnmount(): Allows cleanup before the component is removed from the DOM, e.g., unsubscribing from events.</em></li></ul><blockquote><strong>Error Handling:</strong></blockquote><ul><li><em>componentDidCatch(): Catches errors during rendering or in lifecycle methods of child components, displaying fallback UI.</em></li></ul><p><em>🚀 </em><strong><em>How it works in functional components?</em></strong></p><p>In functional components, React’s traditional lifecycle methods are replaced by React Hooks. The <strong>useState</strong> hook manages state, while the <strong>useEffect</strong> hook handles component lifecycle behaviors such as mounting, updating, and unmounting.</p><p>In functional components, React’s lifecycle methods are replaced by hooks:</p><ul><li>Constructor: Use useState to initialize state.</li><li>componentDidMount: Use useEffect with an empty dependency array for initial mounting effects.</li><li>componentDidUpdate: Use useEffect with specific dependencies for updating effects.</li><li>componentWillUnmount: Return a cleanup function from useEffect.</li><li>getDerivedStateFromProps: Use useState and useEffect to handle prop changes.</li><li>Render: Achieved as the component’s main function.</li></ul><p>Hooks provide a more concise and declarative way to manage component lifecycle and state in functional components.</p><h3>Stackademic</h3><p><em>Thank you for reading until the end. Before you go:</em></p><ul><li><em>Please consider </em><strong><em>clapping</em></strong><em> and </em><strong><em>following</em></strong><em> the writer! 👏</em></li><li><em>Follow us on </em><a href="https://twitter.com/stackademichq"><strong><em>Twitter(X)</em></strong></a><em>, </em><a href="https://www.linkedin.com/company/stackademic"><strong><em>LinkedIn</em></strong></a><em>, and </em><a href="https://www.youtube.com/c/stackademic"><strong><em>YouTube</em></strong></a><strong><em>.</em></strong></li><li><em>Visit </em><a href="http://stackademic.com/"><strong><em>Stackademic.com</em></strong></a><em> to find out more about how we are democratizing free programming education around the world.</em></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=68cf2ed3c51b" width="1" height="1" alt=""><hr><p><a href="https://blog.stackademic.com/react-lifecycle-methods-a-journey-from-class-components-to-functional-components-68cf2ed3c51b">React Lifecycle Methods : 🔓A Journey from Class Components to Functional Components😀</a> was originally published in <a href="https://blog.stackademic.com/">Stackademic</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Virtual DOM In React]]></title>
            <link>https://blog.stackademic.com/virtual-dom-in-react-b04707f164c0?source=rss-401590a4d40a------2</link>
            <guid isPermaLink="false">https://medium.com/p/b04707f164c0</guid>
            <category><![CDATA[virtual-dom]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[reconciliation]]></category>
            <category><![CDATA[react]]></category>
            <category><![CDATA[web-development]]></category>
            <dc:creator><![CDATA[Kavyabhat]]></dc:creator>
            <pubDate>Sat, 19 Aug 2023 05:24:01 GMT</pubDate>
            <atom:updated>2023-09-13T03:17:39.673Z</atom:updated>
            <content:encoded><![CDATA[<blockquote><strong><em>First lets see what is the need of Virtual Dom ? why is it helpful in making React faster ? with easy explanation for understanding!</em></strong></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/442/1*cKe6eHvG5EJ4-pO_f2tfMg.png" /></figure><p>Imagine you’re building a house with blocks. These blocks represent your website’s different parts, like buttons, text, and images. To make changes to your house, you have two choices: you can either change the actual blocks or work with a model of your house.</p><p>In React, the Virtual DOM is like that model of your house made out of paper. Instead of directly changing the real blocks (which would be slow), you make changes on this paper model. When you’re done, you compare the changes you made on the paper model with the actual blocks. Then, you only change the real blocks that need to be changed based on your paper model. This way, you save time and effort.</p><p>So, the Virtual DOM helps React make your website updates faster by first making changes on a pretend version of your site (the Virtual DOM), and then only making the actual changes that are needed on the real site. This way, your website stays up-to-date without a lot of extra work!</p><blockquote><strong>Reconciliation</strong></blockquote><p>In React, this process of comparing the changes you want to make to your user interface, comparing the <strong><em>Virtual DOM</em></strong> with the actual user interface the <strong><em>real DOM</em> </strong>is called <strong>reconciliation</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Y4-yGCozxVfduMeL" /></figure><p>It’s like you’re an efficient builder, updating your block house by making the smallest necessary changes instead of starting from scratch. This way, your app stays responsive and up-to-date without wasting resources.</p><p>Technical Terms :</p><p><strong><em>React creates a copy of original dom to avoid making direct changes in the original. When a change occurs in any state, a new copy of virtual dom is created reflecting that change, Now react will do diffing ( we will learn about diffing in next section ) on the new and earlier version of virtual dom to specify the changes, And now it will batchupdate changes of several virtual doms finally reflect it in the original DOM. This process is called Reconciliation.</em></strong></p><p><strong><em>Batch Update<br></em></strong> <strong><em>React follows a batch update mechanism to update the real DOM. Hence, leading to increased performance. This means that updates to the real DOM are sent in batches, instead of sending updates for every single change in state.</em></strong></p><blockquote><strong>Diffing algorithm</strong></blockquote><p>In React, the “diffing algorithm” does something similar. It compares the previous state of your user interface (like your current block house) with the new state (like the updated block house you want). By spotting the differences and making only the necessary changes, React ensures that your app’s user interface updates quickly and efficiently, just like how you’d update your block house with the least amount of effort.</p><p>Technical Terms:</p><p><strong><em>React compares the current version of the virtual DOM with the previous version of the virtual DOM. This process is called “diffing”.</em></strong></p><p><strong><em>1- If the root or parent element has changed, its child elements are considered to be changed as well and will destroy and rebuild again and change the virtual DOM. If only the attribute of element is changed only that part will be changed as part of batch update and change original DOM.</em></strong></p><p><strong><em>2- When checking li elements, the diff algorithm checks all elements to match for any changes or removed or new element. This takes a toll on performance and that&#39;s why keys are used when printing list items as such, to make the differentiation easier and faster.</em></strong></p><h3>Stackademic</h3><p><em>Thank you for reading until the end. Before you go:</em></p><ul><li><em>Please consider </em><strong><em>clapping</em></strong><em> and </em><strong><em>following</em></strong><em> the writer! 👏</em></li><li><em>Follow us on </em><a href="https://twitter.com/stackademichq"><strong><em>Twitter(X)</em></strong></a><em>, </em><a href="https://www.linkedin.com/company/stackademic"><strong><em>LinkedIn</em></strong></a><em>, and </em><a href="https://www.youtube.com/c/stackademic"><strong><em>YouTube</em></strong></a><strong><em>.</em></strong></li><li><em>Visit </em><a href="http://stackademic.com/"><strong><em>Stackademic.com</em></strong></a><em> to find out more about how we are democratizing free programming education around the world.</em></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b04707f164c0" width="1" height="1" alt=""><hr><p><a href="https://blog.stackademic.com/virtual-dom-in-react-b04707f164c0">Virtual DOM In React</a> was originally published in <a href="https://blog.stackademic.com/">Stackademic</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>