<?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 Rizwan Malek on Medium]]></title>
        <description><![CDATA[Stories by Rizwan Malek on Medium]]></description>
        <link>https://medium.com/@malekrizwan08?source=rss-42577dde9901------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*QRT_z4iVc9YbDyWyAWJlTQ.jpeg</url>
            <title>Stories by Rizwan Malek on Medium</title>
            <link>https://medium.com/@malekrizwan08?source=rss-42577dde9901------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 20 Nov 2026 02:04:24 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@malekrizwan08/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[How AI Is Actually Changing Software Development: A Short, Research‑Backed Take]]></title>
            <link>https://blog.stackademic.com/how-ai-is-actually-changing-software-development-a-short-research-backed-take-4a01e380eb70?source=rss-42577dde9901------2</link>
            <guid isPermaLink="false">https://medium.com/p/4a01e380eb70</guid>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[medium]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <dc:creator><![CDATA[Rizwan Malek]]></dc:creator>
            <pubDate>Fri, 05 Dec 2025 07:03:46 GMT</pubDate>
            <atom:updated>2025-12-08T17:16:31.608Z</atom:updated>
            <content:encoded><![CDATA[<p>AI tools are everywhere — and they’re changing the way developers work. Here’s a short, fact-based summary of what’s happening, what research says, and what it means for our day‑to‑day development workflow.</p><h3>Key Facts (Short &amp; Clear)</h3><ul><li><strong>AI adoption is massive.</strong> Developer surveys show most developers now use AI tools in some part of their workflow.</li><li><strong>Productivity jumps are real.</strong> Controlled studies on tools like GitHub Copilot show big speed boosts — sometimes 30–50% faster on certain tasks.</li><li><strong>But trust issues remain.</strong> Many developers still don’t fully rely on AI-generated code without reviewing it.</li><li><strong>The role is shifting.</strong> Developers are writing slightly less raw code and spending more time reviewing, architecting, and prompting.</li></ul><h3>Faster execution of routine work</h3><p>AI handles repetitive tasks well — scaffolding, tests, boilerplate, and docs. You move faster.</p><h3>Quicker debugging (but verify everything)</h3><p>AI can help explain errors and suggest fixes, though mistakes still happen.</p><h3>Dev role shift: more reviewer, less typist</h3><p>You become the person guiding, validating, and integrating AI suggestions.</p><h3>More AI features in products</h3><p>Companies want to add AI everywhere — sometimes as a real feature, sometimes just because it’s trendy.</p><h3>Practical Tips (Super Short)</h3><ul><li>Always review AI-generated code.</li><li>Add tests + CI checks to catch silent mistakes.</li><li>Track before/after performance to see if AI truly helps.</li><li>Keep juniors coding — avoid skill loss.</li><li>Document when AI contributes to a PR.</li></ul><h3>Common Pitfalls</h3><ul><li><strong>Blind copy-paste</strong> → leads to hidden bugs.</li><li><strong>Feature bloat</strong> → adding AI where it isn’t needed.</li><li><strong>Security leaks</strong> → never paste secrets into prompts.</li><li><strong>Skill atrophy</strong> → balance AI helps with real coding.</li></ul><h3>One Unique Idea: AI as a “Multiplexing Agent”</h3><p>AI lets one developer test multiple ideas fast-you explore many paths, then pick the best one. It multiplies creativity, not just speed.</p><h3>Final Thought</h3><p>AI is reshaping development in measurable ways. It boosts productivity but demands stronger judgment, review skills, and discipline. Developers who pair AI with good engineering habits will thrive.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4a01e380eb70" width="1" height="1" alt=""><hr><p><a href="https://blog.stackademic.com/how-ai-is-actually-changing-software-development-a-short-research-backed-take-4a01e380eb70">How AI Is Actually Changing Software Development: A Short, Research‑Backed Take</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 ReactJS Interview Questions 2026]]></title>
            <link>https://blog.stackademic.com/top-reactjs-interview-questions-2026-57089f384c2e?source=rss-42577dde9901------2</link>
            <guid isPermaLink="false">https://medium.com/p/57089f384c2e</guid>
            <category><![CDATA[interview-preparation]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[frontend-development]]></category>
            <category><![CDATA[reactjs]]></category>
            <category><![CDATA[web-development]]></category>
            <dc:creator><![CDATA[Rizwan Malek]]></dc:creator>
            <pubDate>Tue, 11 Nov 2025 10:11:33 GMT</pubDate>
            <atom:updated>2025-11-11T12:18:44.909Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LQhuGDDisLCCYvJYAXMMyg.png" /><figcaption>Sources: Gemini AI</figcaption></figure><ol><li>What is a <strong>Single Page Application (SPA)</strong> in React?</li><li>What is <strong>JSX,</strong> and why is it used in React?</li><li>What are <strong>Pure Components</strong> in React?</li><li>What is the <strong>difference between state and props</strong>?</li><li>What is the <strong>Virtual DOM</strong> and how does it improve performance?</li><li>What is the <strong>Context API</strong> in React?</li><li>Difference between <strong>Context API and Redux</strong>.</li><li>Why is <strong>React state update asynchronous or slow</strong> sometimes?</li><li>What is a <strong>Reusable Component</strong>?</li><li>What is <strong>useCallback</strong> and when to use it?</li><li>What is <strong>useMemo</strong> and what are its benefits?</li><li>Why do we use a <strong>fallback UI</strong> in React (e.g., in Suspense or error boundaries)?</li><li>What is <strong>Lazy Loading</strong> and how is it implemented in React?</li><li><strong>How many times will this log be printed?</strong></li></ol><pre>useEffect(() =&gt; {<br>  console.log(&quot;Render&quot;);<br>});</pre><p>15 Explain <strong>useEffect</strong> with its dependencies.</p><p>16. How can we <strong>manage authentication</strong> in a React app?</p><p>17. What is <strong>Routing</strong> in React?</p><p>18. How to <strong>get parameters from the URL</strong> inside a component?</p><p>19. How can we <strong>redirect</strong> to a different route in ReactJS?</p><p>20. What is a <strong>Redux Provider</strong> and its purpose?</p><p>21. How can we <strong>sync Context API with Local Storage</strong>?</p><p>22. Why do we use <strong>useReducer</strong>?</p><p>23. Explain <strong>Stateful</strong> and <strong>Stateless</strong> components.</p><p>24. What is the importance of a <strong>key</strong> prop when rendering lists?</p><p>25. What is <strong>React Fiber</strong>?</p><p>26. What are <strong>Controlled</strong> and <strong>Uncontrolled Components</strong>?</p><p>27. How can we <strong>pass data from a child component to a parent</strong>?</p><p>28. What is <strong>Reconciliation</strong> in React?</p><p>29. Why does React use <strong>className</strong> instead of the HTML class attribute?</p><p>30. What are <strong>Fragments</strong> in React?</p><p>31. Why are <strong>Fragments better than extra wrapper divs</strong>?</p><p>32. How can we apply <strong>PropTypes validation</strong> on props in React?</p><p>33. What are the <strong>advantages of ReactJS</strong>?</p><p>34. How to use <strong>styles</strong> in React (inline, CSS modules, styled-components, etc.)?</p><p>35. How can we <strong>handle events</strong> in React?</p><p>36. How do you <strong>conditionally render components</strong> in React?</p><p>37. How do you <strong>memoize a component</strong> in React?</p><p>38. What is <strong>React Strict Mode</strong> and why is it used?</p><p>39. Why can’t we <strong>update props</strong> directly in React?</p><p>40. What are the <strong>common folder structures</strong> used in React projects?</p><p>41. How to implement a <strong>Default (404) or NotFound page</strong> in React Router?</p><p>42. What are the popular <strong>validation libraries</strong> used in ReactJS?</p><p>43. What is <strong>Yup</strong> and how is it used for form validation?</p><p>44. What is a <strong>Reducer</strong> in Redux and how does it work?</p><p>45. What is the <strong>best way to integrate API calls</strong> in React applications?</p><p>46. How can we integrate <strong>Google, Microsoft, or GitHub authentication</strong> in ReactJS?</p><p>47. How can you <strong>manage authentication</strong> securely in ReactJS (tokens, refresh, etc.)?</p><p>48. How can you apply <strong>dynamic and static classes</strong> to a &lt;div&gt; in React?</p><p>49. What are <strong>React Server Components (RSC)</strong>?</p><p>50. What is <strong>React Suspense</strong> and how does it help with data fetching?</p><p>51. Explain <strong>Concurrent Rendering</strong> and how it improves UX.</p><p>52. What is <strong>useTransition</strong> and when is it useful?</p><p>53. How does <strong>Error Boundary</strong> work in React?</p><p>54. What are <strong>Custom Hooks</strong>, and when should you create one?</p><p>55. What is the <strong>difference between useLayoutEffect and useEffect</strong>?</p><p>56. What is <strong>React 19</strong> introducing in terms of features (like Actions, Improved Server Components, etc.)?</p><p><strong>Thank you so much, All the best :)</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=57089f384c2e" width="1" height="1" alt=""><hr><p><a href="https://blog.stackademic.com/top-reactjs-interview-questions-2026-57089f384c2e">Top ReactJS Interview Questions 2026</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[Prompt Engineering Is Just Debugging with Words]]></title>
            <link>https://blog.stackademic.com/prompt-engineering-is-just-debugging-with-words-49afb708ffbb?source=rss-42577dde9901------2</link>
            <guid isPermaLink="false">https://medium.com/p/49afb708ffbb</guid>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[prompt-engineering]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[chatgpt]]></category>
            <dc:creator><![CDATA[Rizwan Malek]]></dc:creator>
            <pubDate>Mon, 01 Sep 2025 04:10:14 GMT</pubDate>
            <atom:updated>2025-11-11T12:18:42.515Z</atom:updated>
            <content:encoded><![CDATA[<h3>What is prompt engineering?</h3><p>AI is everywhere right now, and one of the buzzwords you’ve probably heard is prompt engineering. While it may sound complex and mysterious, for software engineers, it’s actually quite approachable. At its core, prompt engineering is simply debugging with words instead of code. If you’re used to thinking logically, testing, and iterating in programming, you already have the mindset needed to craft effective prompts for AI.</p><h3>Why It Feels Familiar to Developers</h3><p>When we debug code, we:</p><ul><li>Write an input (the code we think should work).</li><li>Get an output (the error or unexpected result).</li><li>Adjust our input step by step until the output looks right.</li></ul><p>Prompt engineering works the same way:</p><ul><li>You write a prompt (your input).</li><li>The AI gives you an output (its response).</li><li>You tweak your words and instructions until the response matches your expectations.</li></ul><p>If you can debug a program, you can debug a prompt.</p><h3>A Very Simple Example</h3><p>Let’s say you want an AI to write a function that adds two numbers in JavaScript.</p><p><strong>First prompt:</strong></p><blockquote>Write code that adds numbers.</blockquote><p><strong>AI Output:</strong></p><blockquote>function add(a, b) {<br> return a + b;<br>}</blockquote><p>Great! That worked. But what if you wanted an example usage?</p><p><strong>Tweaked prompt:</strong></p><blockquote>Write a JavaScript function that adds two numbers and show how to call it.</blockquote><p><strong>AI Output:</strong></p><blockquote>function add(a, b) {<br> return a + b;<br>}</blockquote><blockquote>console.log(add(2, 3)); // Output: 5</blockquote><p>Just like debugging, a small adjustment in the input changes the output.</p><h3>Another Example: Explaining Concepts</h3><p>Imagine you’re stuck explaining closures to a beginner. You try:</p><p><strong>First prompt:</strong></p><pre>Explain closures in JavaScript.</pre><p><strong>AI Output:</strong> A technical explanation with jargon.</p><p>That might be too advanced for your audience. So you debug the prompt:</p><p><strong>Tweaked prompt:</strong></p><pre>Explain closures in JavaScript with a very simple example for a beginner.</pre><p>Now, the AI simplifies its explanation, making it easier to understand. Again, it’s just like debugging — you refine until the output fits.</p><h3>The Developer’s Advantage</h3><p>Software engineers already:</p><ul><li>Break problems into smaller parts.</li><li>Test and adjust inputs to get expected outputs.</li><li>Think logically about cause and effect.</li></ul><p>These are exactly the skills needed for prompt engineering. Others may struggle to understand why wording matters so much, but developers already know that <strong>small changes can have big effects</strong>.</p><h3>Final Thoughts</h3><p>Prompt engineering isn’t magic. It’s not about knowing secret tricks — it’s about experimenting, refining, and thinking logically. For developers, that’s just another day at work. So next time you hear the term “prompt engineering,” don’t overthink it. Remember: it’s just debugging with words.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=49afb708ffbb" width="1" height="1" alt=""><hr><p><a href="https://blog.stackademic.com/prompt-engineering-is-just-debugging-with-words-49afb708ffbb">Prompt Engineering Is Just Debugging with Words</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[What is RTK(Redux Tool Kit)?, How to implement it in ReactJS?]]></title>
            <link>https://medium.com/@malekrizwan08/what-is-rtk-redux-tool-kit-how-to-implement-it-in-reactjs-7664c0e3ca94?source=rss-42577dde9901------2</link>
            <guid isPermaLink="false">https://medium.com/p/7664c0e3ca94</guid>
            <category><![CDATA[reactjs]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[hooks]]></category>
            <category><![CDATA[redux]]></category>
            <dc:creator><![CDATA[Rizwan Malek]]></dc:creator>
            <pubDate>Mon, 23 Oct 2023 06:28:46 GMT</pubDate>
            <atom:updated>2023-10-23T06:28:46.960Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*tv-jz4oqVZsI3fwg" /><figcaption>Image Source: <a href="https://blog.dastasoft.com/_next/image?url=%2Fassets%2Fposts%2Fpreview%2Fredux-toolkit.webp&amp;w=1920&amp;q=75">https://blog.dastasoft.com/_next/image?url=%2Fassets%2Fposts%2Fpreview%2Fredux-toolkit.webp&amp;w=1920&amp;q=75</a></figcaption></figure><h4>Hello Readers And Listeners,</h4><h3><strong>What is RTK(Redux Tool Kit)?</strong></h3><p>Redux Toolkit is an official, opinionated, batteries-included toolset for efficient Redux development. It is intended to be the standard way to write Redux logic, and it includes several utility functions that simplify the most common Redux use cases,</p><ol><li>Store Setup</li><li>Reducers</li><li>Actions</li><li>APIs Calling</li></ol><h3>When To Use RTK(Redux Tool Kit)?</h3><p>If you are writing any Redux logic today, you should be using the Redux Toolkit to write that code! RTK includes utilities that help simplify many common use cases, including store setup, creating reducers writing immutable update logic, and even creating entire “slices” of state at once.</p><h3>Can we able to use RTK(Redux Tool Kit) In Other Frameworks Like NextJS?</h3><p>Yes, We can easily able to use RTK(Redux Tool Kit) In javascript frameworks like nextJS.</p><h3>Can we able to write RTK(Redux Tool Kit) code in Typescript?</h3><p>Yes, We can easily write RTK(Redux Tool Kit) With TypeScript. If you want to learn how can we start RTK(Redux Tool Kit) with TypeScript kindly refer official documentation.</p><p><a href="https://redux-toolkit.js.org/tutorials/typescript">TypeScript Quick Start | Redux Toolkit</a></p><h3>Now Let’s Start RTK(Redux Tool Kit) With JavaScript In ReactJS!</h3><h3>Installation</h3><h4>npm</h4><pre>npm install @reduxjs/toolkit<br>// If you need to react binding, install this package<br>npm install react-redux</pre><h4>yarn</h4><pre>yarn add @reduxjs/toolkit<br>// If you need to react binding, install this package<br>yearn add react-redux</pre><p>If you want to learn more about the installation process follow official documentation link below.</p><p><a href="https://redux-toolkit.js.org/introduction/getting-started">Getting Started | Redux Toolkit</a></p><h3>Set up the store</h3><ol><li>Create the store.js file, Not need to define the file name only and only store.js. You can give any name of the file.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/293/1*kYrbqDDtqizouDY-0Vqn6Q.png" /><figcaption>Image Source: My Local Machine</figcaption></figure><p>2. Configure the store settings. store.js</p><pre>import { configureStore } from &quot;@reduxjs/toolkit&quot;;<br>const store = configureStore({<br>    reducer: {<br>        // Reducers<br>    },<br>    middleware: (getDefaultMiddleware) =&gt; {<br>        // Setup The Middleware Here<br>    }<br>});<br>export default store;</pre><p>3. Bind the store with <strong>Provider</strong>. We need to Add provider setup in the root file.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/310/1*pgMKGets_Qjd4X4d50oMpw.png" /><figcaption>Image Source: My Local Machine</figcaption></figure><p>index.js</p><pre>import React from &#39;react&#39;;<br>import ReactDOM from &#39;react-dom/client&#39;;<br>import App from &#39;./App&#39;;<br>import { Provider } from &#39;react-redux&#39;;<br>import store from &#39;./Redux/store&#39;;<br><br>const root = ReactDOM.createRoot(document.getElementById(&#39;root&#39;));<br>root.render(<br>    &lt;Provider store={store}&gt;<br>        &lt;App /&gt;<br>    &lt;/Provider&gt;);</pre><h3>Set up the Reducers, Slices And Actions</h3><p>We need to create a reducer and slice folder in the Redux folder</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/314/1*PRh9TZc_0nDSYuEntgg5bw.png" /><figcaption>Image Source: My Local Machine</figcaption></figure><h3>Slices</h3><p>A <strong>“slice”</strong> is a collection of Redux reducer logic and actions for a single feature in your app, typically defined together in a single file. We can create slices like this found in the below code.</p><pre>import { createSlice } from &quot;@reduxjs/toolkit&quot;;<br><br>const initialState = {<br>    // Others States<br>};<br>const &lt;SliceName&gt; = createSlice({<br>    name: &lt;Name Of Slice&gt;, // Name Of Slice<br>    initialState, // Initial State<br>    reducers: {<br>        // Reducers<br>    }<br>});<br>export default &lt;SliceName&gt;;</pre><h3>Reducers</h3><p>A reducer is a function that takes in the current state of an application and an action as arguments and returns a new state based on the action. A simple example of. Todo Reducers Below</p><pre>import { createSlice } from &quot;@reduxjs/toolkit&quot;;<br><br>const initialState = {<br>    list: []<br>    // Others States<br>};<br>const todoSlice = createSlice({<br>    name: &quot;Todo&quot;, // Name Of Slice<br>    initialState, // Initial State<br>    reducers: {<br>        AddTodo(state, { payload }) { // payload<br>            // Updates The State Here<br>        }<br>    }<br>});<br>export default todoSlice;</pre><h4>Payload</h4><p>Payload is parameters values, We get the data from actions dispatch.</p><h4>We Can Also able to create all the reducers for a particular slice for another file.</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/299/1*ILY97m0if9gGZ6-iNQEHPw.png" /><figcaption>Image Source: My Local Machine</figcaption></figure><p>/Redux/reducers/todo.js</p><pre>export default todoRootReducer = {<br>    AddTodo(state, { payload }) {<br>        // code<br>    },<br>    DeleteTodo(state, { payload }) {<br>        // code<br>    },<br>    UpdateTodo(state, { payload }) {<br>        // code<br>    },<br>    SortTodo(state, { payload }) {<br>        // code<br>    },<br>}</pre><p>/Redux/slices/todo.js</p><pre>import { createSlice } from &quot;@reduxjs/toolkit&quot;;<br>import todoRootReducer from &quot;../reducers/todo&quot;;<br><br>const initialState = {<br>    list: []<br>    // Others States<br>};<br>const todoSlice = createSlice({<br>    name: &quot;Todo&quot;, // Name Of Slice<br>    initialState, // Initial State<br>    reducers: todoRootReducer<br>});<br>export default todoSlice;</pre><h4>We Can Also Create Root Slices For Reducers</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/274/1*PeTIJ5ElVTgd5Q3qc4fy6w.png" /><figcaption>Image Source: My Local Machine</figcaption></figure><p>/Redux/slices/index.js</p><pre>import { combineReducers } from &quot;@reduxjs/toolkit&quot;;<br>import todoSlice from &quot;./todo&quot;;<br><br>const rootReducer = combineReducers({<br>    todo: todoSlice.reducer<br>});<br>export default rootReducer;</pre><h4>What is combineReducers</h4><p>The combineReducers helper function turns an object whose values are different reducing functions into a single reducing function you can pass to <a href="https://redux.js.org/api/createstore">createStore</a>.</p><h4>Now Setting Up The Store For Root Reducers</h4><pre>import { configureStore } from &quot;@reduxjs/toolkit&quot;;<br>import rootReducer from &quot;./slices&quot;;<br><br>const store = configureStore({<br>    reducer: rootReducer, // root reducers<br>    middleware: (getDefaultMiddleware) =&gt; {<br>        // Setup The Middleware Here<br>    }<br>});<br>export default store;</pre><h4>How Can We Create Actions?</h4><p>In RTK We don’t need to create the actions like in Redux. We just need to extract from the slices. Let me show the examples of Actions</p><p>/Redux/slices/todo.js</p><pre>import { createSlice } from &quot;@reduxjs/toolkit&quot;;<br>import todoRootReducer from &quot;../reducers/todo&quot;;<br><br>const initialState = {<br>    list: []<br>    // Others States<br>};<br>const todoSlice = createSlice({<br>    name: &quot;Todo&quot;, // Name Of Slice<br>    initialState, // Initial State<br>    reducers: todoRootReducer<br>});<br><br>export const todoActions = todoSlice.actions; // We Got Actions Here<br>export default todoSlice;</pre><h4>How To Dispatch With The Actions?</h4><p>/App.js</p><pre>import { useDispatch } from &quot;react-redux&quot;;<br>import { todoActions } from &quot;./Redux/slices/todo&quot;;<br>import { useState } from &quot;react&quot;;<br><br>function App() {<br>  const dispatch = useDispatch();<br>  const [title, setTitle] = useState(&quot;&quot;);<br>  const [description, setDescription] = useState(&quot;&quot;);<br><br>  const handleAddTodo = () =&gt; {<br>    dispatch(todoActions.AddTodo({ title, description })); // dispatch here<br>  }<br>  return (&lt;&gt;<br>    &lt;h1&gt;Todo Application&lt;/h1&gt;<br>    &lt;label&gt;Title&lt;/label&gt;<br>    &lt;input value={title} onChange={(e) =&gt; setTitle(e.target.value)} type=&quot;text&quot; /&gt;<br>    &lt;label&gt;Description&lt;/label&gt;<br>    &lt;input value={description} onChange={(e) =&gt; setDescription(e.target.value)} type=&quot;text&quot; /&gt;<br>    &lt;button onClick={handleAddTodo}&gt;Click&lt;/button &gt;<br>  &lt;/&gt;);<br>}<br><br>export default App;</pre><p>Here,</p><p>We have created two states for managing the title and description values, Import the todoActions from the todo.js slices, We need to import useDispatch hook and create the instance of useDispatch,</p><p>Now in the handleAddTodo function, we can able to dispatch with the AddTodo Actions.</p><h3>Asynchronous Operations With The RTK Or APIs Calling.</h3><h4>About createAsyncThunk</h4><p>createAsyncThunk will generate three Redux action creators using createAction : pending , fulfilled , and rejected . Each lifecycle action creator will be attached to the returned thunk action creator so that your reducer logic can reference the action types and respond to the actions when dispatched.</p><h4>How Can We Create The Async Actions?</h4><pre>import { createAsyncThunk} from &quot;@reduxjs/toolkit&quot;;<br>const getTodoList = createAsyncThunk(&quot;getTodoList&quot;, async () =&gt; {<br>    // Code Here<br>});</pre><h4>Get Todo List Example</h4><pre>const getTodoList = createAsyncThunk(&quot;getTodoList&quot;, async (payload, { rejectWithValue }) =&gt; {<br>    try {<br>        const response = await fetch(&quot;https://jsonplaceholder.typicode.com/todos&quot;);<br>        const data = await response.json();<br>        return data;<br>    } catch (error) {<br>        return rejectWithValue(error);<br>    }<br>});</pre><p>Here we wrote the basic todos get API with JSON placeholder</p><p>If you want to learn about JSON placeholder kindly follow the below link.</p><p><a href="https://jsonplaceholder.typicode.com/">JSONPlaceholder</a></p><h4>Now, Integrate the async operation with slices</h4><pre>const initialState = {<br>    list: []<br>    // Others States<br>};<br>const todoSlice = createSlice({<br>    name: &quot;Todo&quot;, // Name Of Slice<br>    initialState, // Initial State<br>    reducers: todoRootReducer,<br>    extraReducers: (builder) =&gt; {<br>        // Manage State Here<br>    }<br>});</pre><h4>About the extraReducers</h4><p>extraReducers allows createSlice to respond and update its own state in response to other action types besides the types it has generated. As with the reducers field, each case reducer in extraReducers is wrapped in Immer and may use “mutating” syntax to safely update the state inside.</p><h4>About builder</h4><p>Usage with the “Builder Callback” Notation​ This overload accepts a callback function that receives a builder object as its argument. That builder provides addCase, addMatcher and addDefaultCase functions that may be called to define what actions this reducer will handle.</p><h4>Async Status</h4><pre>extraReducers: (builder) =&gt; {<br>        builder.addCase(getTodoList.pending, (state) =&gt; {<br>            state.isLoading = true;<br>        });<br>        builder.addCase(getTodoList.fulfilled, (state) =&gt; {<br>            state.list = payload.data;<br>            state.isLoading = false;<br>        });<br>        builder.addCase(getTodoList.rejected, (state) =&gt; {<br>            state.isLoading = false;<br>        });<br>    }</pre><p>/Redux/slices/todo.js</p><pre>import { createAsyncThunk, createSlice } from &quot;@reduxjs/toolkit&quot;;<br>import todoRootReducer from &quot;../reducers/todo&quot;;<br><br>const getTodoList = createAsyncThunk(&quot;getTodoList&quot;, async (payload, { rejectWithValue }) =&gt; {<br>    try {<br>        const response = await fetch(&quot;https://jsonplaceholder.typicode.com/todos&quot;);<br>        const data = await response.json();<br>        return data;<br>    } catch (error) {<br>        return rejectWithValue(error);<br>    }<br>});<br><br><br>const initialState = {<br>    list: [],<br>    isLoading: false,<br>    // Others States<br>};<br>const todoSlice = createSlice({<br>    name: &quot;Todo&quot;, // Name Of Slice<br>    initialState, // Initial State<br>    reducers: todoRootReducer,<br>    extraReducers: (builder) =&gt; {<br>        builder.addCase(getTodoList.pending, (state) =&gt; {<br>            state.isLoading = true;<br>        });<br>        builder.addCase(getTodoList.fulfilled, (state) =&gt; {<br>            state.list = payload.data;<br>            state.isLoading = false;<br>        });<br>        builder.addCase(getTodoList.rejected, (state) =&gt; {<br>            state.isLoading = false;<br>        });<br>    }<br>});<br><br>export const todoActions = todoSlice.actions; // We Got Actions Here<br>export default todoSlice;</pre><h4>Now Dispatch The Async operations</h4><p>First We need to export the async functions</p><pre>export const getTodoList = createAsyncThunk(&quot;getTodoList&quot;, async (payload, { rejectWithValue }) =&gt; {<br>    try {<br>        const response = await fetch(&quot;https://jsonplaceholder.typicode.com/todos&quot;);<br>        const data = await response.json();<br>        return data;<br>    } catch (error) {<br>        return rejectWithValue(error);<br>    }<br>});</pre><h4>Now dispatch the function</h4><pre> dispatch(getTodoList());</pre><h4>Getting RTK Values</h4><p>First, we need to import the useSelector hook</p><pre>import { useSelector } from &quot;react-redux&quot;;</pre><p>Then get the values from the hook</p><pre> const { isLoading, list } = useSelector(state =&gt; state.todo);</pre><p>Now Use the values in UI.</p><h4>There is any way to add the Redux Dev Tool With RTK?</h4><p>In the RTK Already added the Dev Tool, We just need to enable the tool.</p><pre>import { configureStore } from &quot;@reduxjs/toolkit&quot;;<br>import rootReducer from &quot;./slices&quot;;<br><br>const store = configureStore({<br>    devTools: true, // true for enable, false for disable<br>    reducer: rootReducer,<br>    middleware: (getDefaultMiddleware) =&gt; {<br>        // Setup The Middleware Here<br>    }<br>});<br>export default store;</pre><p>If you want to learn more about the RTK Follow the below link</p><p><a href="https://redux-toolkit.js.org/">Redux Toolkit</a></p><p>If you want to learn about React kindly follow the below link</p><p><a href="https://react.dev/">React</a></p><h4>You Can Follow Me On Linkedin</h4><p><a href="https://in.linkedin.com/in/rizwan-malek-9529b9196">https://in.linkedin.com/in/rizwan-malek-9529b9196</a></p><h4>Thank You So Much For Reading My Article :)</h4><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7664c0e3ca94" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Top JavaScript Interview Questions For New Graduates]]></title>
            <link>https://medium.com/@malekrizwan08/top-javascript-interview-questions-for-new-graduates-85f9e9ae114e?source=rss-42577dde9901------2</link>
            <guid isPermaLink="false">https://medium.com/p/85f9e9ae114e</guid>
            <category><![CDATA[interview]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[learning]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[medium]]></category>
            <dc:creator><![CDATA[Rizwan Malek]]></dc:creator>
            <pubDate>Fri, 13 Oct 2023 06:27:19 GMT</pubDate>
            <atom:updated>2023-10-13T06:27:19.688Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*wjvUsz1HVQNEsLcz.jpg" /><figcaption>Image source — <a href="https://fjwp.s3.amazonaws.com/blog/wp-content/uploads/2023/02/13061142/30-of-the-Most-Common-Job-Interview-Questions-With-Example-Answers-1024x512.jpg">https://fjwp.s3.amazonaws.com/blog/wp-content/uploads/2023/02/13061142/30-of-the-Most-Common-Job-Interview-Questions-With-Example-Answers-1024x512.jpg</a></figcaption></figure><p>Hello, readers and listeners :)</p><h3>1. What is JSON?</h3><ul><li>JSON stands for JavaScript Object Notation.</li><li>It is a lightweight data-interchange format that is easy for humans to read and write. It is also easy for machines to parse and generate.</li><li>JSON is based on two structures: objects and arrays. Objects are collections of key-value pairs, and arrays are ordered lists of values.</li></ul><pre>[<br>  {<br>    &quot;name&quot;: &quot;Rizwan&quot;,<br>    &quot;age&quot;: &quot;23&quot;<br>  }<br>]<br></pre><h3>2. What is the array slice method?</h3><ul><li>The slice() method in JavaScript returns a shallow copy of a portion of an array into a new array object.</li><li>The slice() the method takes two optional parameters: begin and end. The begin the parameter defines the starting index from where the portion is to be extracted. The end parameter is the index up to which the portion is to be extracted (excluding the end index). If the end parameter is not specified, the slice will go to the end of the array.</li></ul><pre>const array = [1, 2, 3, 4, 5];<br>const newArray = array.slice(1, 3);<br>console.log(newArray); // [2, 3]</pre><h3>3. What is the difference between slice and splice?</h3><ul><li>The slice() method returns a new array that contains a portion of the original array.</li><li>The splice() method modifies the original array by adding or removing elements.</li><li>The slice() the method takes 2 parameters, while the splice() method takes 3 or more parameters.</li></ul><pre>const myArray = [1, 2, 3, 4, 5];<br><br>const newArray = myArray.slice(2, 4); // Returns a new array with the elements 3 and 4<br><br>myArray.splice(2, 1); // Removes the element at index 2 from the original array<br><br>console.log(myArray); // [1, 2, 4, 5]<br>console.log(newArray); // [3, 4]</pre><h3>4. What is the difference between == and === operators</h3><ul><li>The == the operator performs loose equality, while the === the operator performs strict equality.</li><li>The == the operator will convert the values to the same type before comparing them, while the === the operator will only compare the values if they are already of the same type.</li></ul><pre>const a = 1000;<br>const b = &quot;1000&quot;;<br><br>console.log(a == b); // true</pre><pre>const a = 1;<br>const b = &quot;1&quot;;<br><br>console.log(a === b); // false</pre><pre>0 == false   // true<br>0 === false  // false<br>1 == &quot;1&quot;     // true<br>1 === &quot;1&quot;    // false<br>null == undefined // true<br>null === undefined // false<br>&#39;0&#39; == false // true<br>&#39;0&#39; === false // false<br>[]==[] or []===[] //false, refer different objects in memory<br>{}=={} or {}==={} //false, refer different objects in memory<br>// Credit for this https://github.com/sudheerj</pre><h3>5. What are lambda or arrow functions?</h3><ul><li>Lambda or arrow functions are a concise way to write anonymous functions in JavaScript.</li><li>They are similar to regular functions, but they have some key differences.</li><li>Syntax: Arrow functions use the =&gt; syntax instead of the function keyword.</li><li>Scope: Arrow functions have a narrower scope than regular functions.</li><li>Arguments: Arrow functions can have a single parameter, or they can have no parameters at all.</li><li>Return value: Arrow functions can return a value by simply assigning the value to the arrow operator.</li></ul><pre>const double = x =&gt; x * 2;</pre><h3>6. What is a higher-order function?</h3><ul><li>A higher-order function is a function that takes one or more functions as arguments or returns a function as its result.</li><li>Higher-order functions are a powerful tool that can be used to simplify and improve the readability of JavaScript code. They allow us to abstract over actions, not just values.</li></ul><pre>const numbers = [1, 2, 3, 4, 5];<br><br>const doubledNumbers = numbers.map(double);<br><br>console.log(doubledNumbers); // [2, 4, 6, 8, 10]</pre><ul><li>higher-order functions in JavaScript: map(), filter(), and reduce().</li><li>We can also create a custom higher-order function</li></ul><pre>const twoNumberOfSum = (n1,n2) =&gt; n1 + n2;<br>console.log(twoNumberOfSum(10,20)); // 30<br>console.log(twoNumberOfSum(3,3)); // 6</pre><h3>7. What is the purpose of the let keyword?</h3><ul><li>The let keyword in JavaScript is used to declare a block-scoped variable.</li><li>This means that the variable is only accessible within the block in which it is declared.</li><li>Block scope is a newer feature in JavaScript, introduced in ECMAScript 6 (ES6).</li><li>It was created to improve the readability and maintainability of JavaScript code.</li></ul><pre>{<br>  let x = 10;<br>}</pre><h3>8. What is the difference between let and var</h3><ul><li>let and var are keywords used to declare variables in JavaScript.</li><li>let variables have block scope, while var variables have function scope.</li><li>let variables are not hoisted, while var variables are.</li><li>let variables cannot be redeclared, while var variables can be redeclared.</li></ul><pre>console.log(varVariable) // undefined value no error<br>var varVariable = &#39;VAR&#39;;<br>console.log(letVariable) // error not found letVariable<br>let letVariable = &#39;LET&#39;;</pre><h3>9. What is the Temporal Dead Zone?</h3><ul><li>The Temporal Dead Zone is a behavior in JavaScript that occurs when declaring a variable with the let and const keywords, but not with var.</li><li>In ECMAScript 6, accessing a let or const variable before its declaration (within its scope) causes a ReferenceError. The time span when that happens, between the creation of a variable’s binding and its declaration, is called the temporal dead zone.</li></ul><pre>function somemethod() {<br>  console.log(counter1); // undefined<br>  console.log(counter2); // ReferenceError<br>  var counter1 = 1;<br>  let counter2 = 2;<br>}</pre><h3>10. What is IIFE(Immediately Invoked Function Expression)?</h3><ul><li>IIFE (Immediately Invoked Function Expression) is a JavaScript function that runs as soon as it is defined. The signature of it would be as below,</li></ul><pre>(function () {<br>  // logic here<br>})();</pre><ul><li>The primary reason to use an IIFE is to obtain data privacy because any variables declared within the IIFE cannot be accessed by the outside world. i.e, If you try to access variables with IIFE then it throws an error as below,</li></ul><pre>(function () {<br>  var message = &quot;IIFE&quot;;<br>  console.log(message);<br>})();<br>console.log(message); //Error: message is not defined</pre><h3>11. How do you decode or encode a URL in JavaScript?</h3><ul><li>To decode or encode a URL in JavaScript, you can use the encodeURIComponent() and decodeURI() functions. The encodeURIComponent() function encodes a URL, while the decodeURI() function decodes a URL.</li></ul><pre>let uri = &quot;employeeDetails?name=john&amp;occupation=manager&quot;;<br>let encoded_uri = encodeURI(uri);<br>let decoded_uri = decodeURI(encoded_uri);</pre><h3>12. What is memorization?</h3><ul><li>Memoization is an optimization technique that stores the results of expensive function calls in a cache so that they can be reused when the same inputs are provided again. This can significantly improve the performance of a program by avoiding the need to repeatedly compute the same results.</li></ul><pre>const memoize = function(func) {<br>  const cache = {};<br>  return function(input) {<br>    if (input in cache) {<br>      return cache[input];<br>    } else {<br>      const result = func(input);<br>      cache[input] = result;<br>      return result;<br>    }<br>  };<br>};</pre><h3>13. What is Hoisting?</h3><p>In JavaScript, Hoisting is the default behaviour of moving all the declarations at the top of the scope before code execution. Basically, it gives us an advantage that no matter where functions and variables are declared, they are moved to the top of their scope regardless of whether their scope is global or local.</p><pre><br> // Hoisting<br> function codeHoist(){<br>  a = 10;<br>  let b = 50;<br> }<br> codeHoist();<br><br> console.log(a); // 10<br> console.log(b); // ReferenceError : b is not defined<br></pre><h3>14. What is a moduler programming?</h3><p>JavaScript modules allow you to break up your code into separate files. This makes it easier to maintain a code base. Modules are imported from external files with the import statement. Modules also rely on type=&quot;module&quot; in the &lt;script&gt; tag.</p><pre>&lt;script type=&quot;module&quot;&gt;<br>  import message from &quot;./message.js&quot;;<br>&lt;/script&gt;</pre><pre>const name = &quot;Jesse&quot;;<br>const age = 40;<br><br>export {name, age};</pre><h3>15. What is ES6?</h3><p>ES6 stands for ECMAScript 6.</p><p>ECMAScript was created to standardize JavaScript, and ES6 is the 6th version of ECMAScript, it was published in 2015 and is also known as ECMAScript 2015.</p><p>JavaScript ES6 brings new syntax and awesome features to make your code more modern and more readable. It allows you to write less code and do more. ES6 introduces us to many great features like arrow functions, template strings, class destruction, Modules and more.</p><h3>16. What are closures</h3><p>A closure is the combination of a function and the lexical environment within which that function was declared. i.e., It is an inner function that has access to the outer or enclosing function’s variables. The closure has three scope chains</p><ol><li>Own scope where variables are defined between its curly brackets</li><li>Outer function variables</li><li>Global variables</li></ol><p>Let’s take an example of the closure concept,</p><pre>function Welcome(name) {<br>  var greetingInfo = function (message) {<br>    console.log(message + &quot; &quot; + name);<br>  };<br>  return greetingInfo;<br>}<br>var myFunction = Welcome(&quot;John&quot;);<br>myFunction(&quot;Welcome &quot;); //Output: Welcome John<br>myFunction(&quot;Hello Mr.&quot;); //output: Hello Mr.John</pre><p>As per the above code, the inner function(i.e, greetingInfo) has access to the variables in the outer function scope(i.e, Welcome) even after the outer function has returned.</p><h3>17. What is the scope in javascript</h3><p>Scope determines the accessibility of variables, objects, and functions from different parts of the code.</p><p>If you assign a value to a variable that has not been declared, it will automatically become a <strong>GLOBAL</strong> variable.</p><p>This code example will declare a global variable carName, even if the value is assigned inside a function.</p><pre>myFunction();<br><br>// code here can use carName<br><br>function myFunction() {<br>  carName = &quot;Volvo&quot;;<br>}</pre><h3>18. What is web storage</h3><p>Web storage is an API that provides a mechanism by which browsers can store key/value pairs locally within the user’s browser, in a much more intuitive fashion than using cookies. The web storage provides two mechanisms for storing data on the client.</p><ol><li>Local storage: It stores data for current origin with no expiration date.</li><li>Session storage: It stores data for one session and the data is lost when the browser tab is closed.</li></ol><h3>19. Why do you need web storage</h3><p>Web storage is more secure, and large amounts of data can be stored locally, without affecting website performance. Also, the information is never transferred to the server. Hence this is a more recommended approach than Cookies.</p><p>We can also use web storage for storing the token for authentication and for other user</p><h3>20. What is a promise?</h3><p>A Promise is a proxy for a value not necessarily known when the promise is created. It allows you to associate handlers with an asynchronous action&#39;s eventual success value or failure reason. This lets asynchronous methods return values like synchronous methods: instead of immediately returning the final value, the asynchronous method returns a <em>promise</em> to supply the value at some point in the future.</p><p>A Promise is in one of these states:</p><ul><li><em>pending</em>: initial state, neither fulfilled nor rejected.</li><li><em>fulfilled</em>: meaning that the operation was completed successfully.</li><li><em>rejected</em>: meaning that the operation failed.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/801/0*LpgIquzqqvx1MYvI.png" /><figcaption>Image Source: <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/promises.png">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/promises.png</a></figcaption></figure><p>The syntax of Promise creation looks like below,</p><pre>const promise = new Promise(function (resolve, reject) {<br>  // promise description<br>});</pre><p>The usage of a promise would be as below,</p><pre>const promise = new Promise(<br>  (resolve) =&gt; {<br>    setTimeout(() =&gt; {<br>      resolve(&quot;I&#39;m a Promise!&quot;);<br>    }, 5000);<br>  },<br>  (reject) =&gt; {}<br>);<br><br>promise.then((value) =&gt; console.log(value));</pre><h3>21. Why do you need a promise</h3><p>It allows you to associate handlers with an asynchronous action’s eventual success value or failure reason. This lets asynchronous methods return values like synchronous methods: instead of immediately returning the final value, the asynchronous method returns a promise to supply the value at some point in the future.</p><h3>22. What are the three states of promise</h3><p>Promises have three states:</p><ol><li>Pending: This is an initial state of the Promise before an operation begins</li><li>Fulfilled: This state indicates that the specified operation was completed.</li><li>Rejected: This state indicates that the operation was not complete. In this case, an error value will be thrown.</li></ol><h3>23. What is a callback function</h3><p>A JavaScript callback is a function which is to be executed after another function has finished execution. A more formal definition would be — Any function that is passed as an argument to another function so that it can be executed in that other function is called as a callback function.</p><p>Example for callback</p><pre>const fetchData = (url, callback) =&gt; {<br>  try{<br>     // Fetch The Data With URL <br>     callback(); // After the successfully fetch data callback function call<br>  }catch(error){<br>    // error handle<br>  }<br>}</pre><h3>24. What is a callback hell</h3><p>Callback Hell is an anti-pattern with multiple nested callbacks which makes code hard to read and debug when dealing with asynchronous logic. The callback hell looks like below,</p><p>Example</p><pre>async1(function(){<br>    async2(function(){<br>        async3(function(){<br>            async4(function(){<br>                ....<br>            });<br>        });<br>    });<br>});</pre><h3>25. What is a callback in the callback</h3><p>You can nest one callback inside in another callback to execute the actions sequentially one by one. This is known as callbacks in callbacks.</p><pre>loadScript(&quot;/script1.js&quot;, function (script) {<br>  console.log(&quot;first script is loaded&quot;);<br><br>  loadScript(&quot;/script2.js&quot;, function (script) {<br>    console.log(&quot;second script is loaded&quot;);<br><br>    loadScript(&quot;/script3.js&quot;, function (script) {<br>      console.log(&quot;third script is loaded&quot;);<br>      // after all scripts are loaded<br>    });<br>  });<br>});</pre><h3>26. What is promise chaining</h3><p>Promise Chaining: Promise Chaining is a simple concept by which we may initialize another promise inside our .then() method and accordingly we may execute our results. The function inside then captures the value returned by the previous promise.</p><pre>new Promise(function (resolve, reject) {<br>  setTimeout(() =&gt; resolve(1), 1000);<br>})<br>  .then(function (result) {<br>    console.log(result); // 1<br>    return result * 2;<br>  })<br>  .then(function (result) {<br>    console.log(result); // 2<br>    return result * 3;<br>  })<br>  .then(function (result) {<br>    console.log(result); // 6<br>    return result * 4;<br>  });</pre><h3>27. What is promise.all</h3><p>The Promise.all() static method takes an iterable of promises as input and returns a single <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise">Promise</a>. This returned promise fulfils when all of the input&#39;s promises are fulfill (including when an empty iterable is passed), with an array of the fulfilment values. It rejects when any of the input&#39;s promises is rejected, with this first rejection reason.</p><pre>const promise1 = Promise.resolve(3);<br>const promise2 = 42;<br>const promise3 = new Promise((resolve, reject) =&gt; {<br>  setTimeout(resolve, 100, &#39;foo&#39;);<br>});<br><br>Promise.all([promise1, promise2, promise3]).then((values) =&gt; {<br>  console.log(values);<br>});<br>// Expected output: Array [3, 42, &quot;foo&quot;]</pre><h3>28. what is a strict mode in javascript</h3><p>Strict mode changes previously accepted “bad syntax” into real errors. As an example, in normal JavaScript, mistyping a variable name creates a new global variable. In strict mode, this will throw an error, making it impossible to accidentally create a global variable.</p><h3>29. How do you declare a strict mode</h3><p>Strict mode is declared by adding “use strict”; to the beginning of a script or a function.</p><pre>&quot;use strict&quot;;<br>x = 3.14;       // This will cause an error because x is not declared</pre><h3>30. What is the purpose of double exclamation</h3><p>In some programming languages, two exclamation marks before a variable mean “not”. It is an operator used to negate the value of a boolean expression i.e. it will evaluate the expression to the opposite of its normal truth value. In the code example above, the first let statement sets a value of true.</p><pre>let isIE8 = false;<br>isIE8 = !!navigator.userAgent.match(/MSIE 8.0/);<br>console.log(isIE8); // returns true or false</pre><h3>31. What is the purpose of the delete operator</h3><p>The delete operator removes a property from an object. If the property’s value is an object and there are no more references to the object, the object held by that property is eventually released automatically.</p><pre>var user = { name: &quot;John&quot;, age: 20 };<br>delete user.age;<br><br>console.log(user); // {name: &quot;John&quot;}</pre><h3>32. What is undefined property</h3><p>The undefined property indicates that a variable has not been assigned a value, or declared but not initialized at all. The type of undefined value is undefined too.</p><pre>var user; // Value is undefined, type is undefined<br>console.log(typeof user); //undefined</pre><p>Any variable can be emptied by setting the value to undefined.</p><pre>user = undefined;</pre><h3>33. What is null value</h3><p>The value null represents the intentional absence of any object value. It is one of JavaScript’s primitive values. The type of null value is object. You can empty the variable by setting the value to null.</p><pre>var user = null;<br>console.log(typeof user); //object</pre><h3>34. What is the difference between a window and a document</h3><p>The window is at a root/top level at the JavaScript object hierarchy. It is a global/root object in JavaScript and it is the root object of the Document object model(DOM); What is a JavaScript document? A document is an object inside the window object and we use a document object for manipulation inside the document.</p><h3>35. What is npm?</h3><p>npm stands for Node Package Manager. It’s a library and registry for JavaScript software packages. npm also has command-line tools to help you install the different packages and manage their dependencies.</p><p><strong>npm</strong> is free to use.</p><p><strong>npm</strong> includes a <strong>CLI</strong> (Command Line Client) that can be used to download and install software:</p><pre>C:\&gt;npm install &lt;package&gt;</pre><p>Official website of npm if you want to learn about npm in detail please follow this link.</p><p><a href="https://www.npmjs.com/">npm | Home</a></p><h3>35. What is isNaN</h3><p>The isNaN() function is used to determine whether a value is an illegal number (Not-a-Number) or not. i.e, This function returns true if the value equates to NaN. Otherwise it returns false.</p><pre>isNaN(&quot;Hello&quot;); //true<br>isNaN(&quot;100&quot;); //false</pre><h3>36. What are global variables</h3><p>Global variables are those that are available throughout the length of the code without any scope. The var keyword is used to declare a local variable but if you omit it then it will become a global variable</p><pre>msg = &quot;Hello&quot;; // var is missing, it becomes global variable</pre><h3>37. How do you submit a form using JavaScript</h3><p>You can submit a form using document.forms[0].submit(). All the form input&#39;s information is submitted using onsubmit event handler</p><pre>function submit() {<br>  document.forms[0].submit();<br>}</pre><h3>38. What are the tools or techniques used for debugging JavaScript code</h3><p>You can use below tools or techniques for debugging javascript</p><ol><li>Chrome Devtools</li><li>debugger statement</li><li>Good old console.log statement</li></ol><h3>39. Is JavaScript a case-sensitive language</h3><p>JavaScript is a case-sensitive language. This means that language keywords, variables, function names, and any other identifiers must always be typed with a consistent capitalization of letters. The while keyword, for example, must be typed “while”, not “While” or “WHILE”.</p><h3>40. What are events</h3><p>Events are “things” that happen to HTML elements. When JavaScript is used in HTML pages, JavaScript can react on these events. Some of the examples of HTML events are,</p><ol><li>The web page has finished loading</li><li>The input field was changed</li><li>Button was clicked</li></ol><p>Let’s describe the behaviour of the click event for the button element,</p><pre>&lt;!doctype html&gt;<br>&lt;html&gt;<br> &lt;head&gt;<br>   &lt;script&gt;<br>     function greeting() {<br>       alert(&#39;Hello! Good morning&#39;);<br>     }<br>   &lt;/script&gt;<br> &lt;/head&gt;<br> &lt;body&gt;<br>   &lt;button type=&quot;button&quot; onclick=&quot;greeting()&quot;&gt;Click me&lt;/button&gt;<br> &lt;/body&gt;<br>&lt;/html&gt;</pre><h3>41. What is the use of setInterval</h3><p>The setInterval() function is commonly used to set a delay for functions that are executed again and again, such as animations. You can cancel the interval using clearInterval() . If you wish to have your function called once after the specified delay, use setTimeout() .</p><pre>setInterval(function () {<br>  console.log(&quot;Good morning&quot;);<br>}, 2000);</pre><h3>42. What is ECMAScript</h3><p>ECMAScript, also known as JavaScript, is a programming language adopted by the European Computer Manufacturer’s Association as a standard for performing computations in Web applications. ECMAScript is the official client-side scripting language of VoiceXML.</p><p>ECMAScript is the scripting language that forms the basis of JavaScript. ECMAScript standardized by the ECMA International standards organization in the ECMA-262 and ECMA-402 specifications. The first edition of ECMAScript was released in 1997.</p><h3>43. What is the purpose JSON stringify</h3><p>When sending data to a web server, the data has to be in a string format. You can achieve this by converting JSON object into a string using stringify() method.</p><pre>var userJSON = { name: &quot;John&quot;, age: 31 };<br>var userString = JSON.stringify(userJSON);<br>console.log(userString); //&quot;{&quot;name&quot;:&quot;John&quot;,&quot;age&quot;:31}&quot;</pre><h3>44. What are PWAs</h3><p>Progressive web applications (PWAs) are a type of mobile app delivered through the web, built using common web technologies including HTML, CSS and JavaScript. These PWAs are deployed to servers, accessible through URLs, and indexed by search engines.</p><h3>45. How do you redirect new page in javascript</h3><p>In vanilla javascript, you can redirect to a new page using the location property of window object. The syntax would be as follows,</p><pre>function redirect() {<br>  window.location.href = &quot;newPage.html&quot;;<br>}</pre><h3>46. How do you get the current url with javascript</h3><p>You can use window.location.href expression to get the current url path and you can use the same expression for updating the URL too. You can also use document.URL for read-only purposes but this solution has issues in FF.</p><pre>console.log(&quot;location.href&quot;, window.location.href); // Returns full URL</pre><h3>47. How do get query string values in javascript</h3><p>You can use URLSearchParams to get query string values in javascript. Let’s see an example to get the client code value from URL query string,</p><pre>const urlParams = new URLSearchParams(window.location.search);<br>const clientCode = urlParams.get(&quot;clientCode&quot;);</pre><h3>48. How do you check if a key exists in an object</h3><p>You can check whether a key exists in an object or not using three approaches,</p><ol><li>Using in operator: You can use the in operator whether a key exists in an object or not</li></ol><pre>&quot;key&quot; in obj;</pre><p>and If you want to check if a key doesn’t exist, remember to use parenthesis,</p><pre>!(&quot;key&quot; in obj);</pre><p>2. Using hasOwnProperty method: You can use hasOwnProperty to particularly test for properties of the object instance (and not inherited properties)</p><pre>obj.hasOwnProperty(&quot;key&quot;); // true</pre><p>3. Using undefined comparison: If you access a non-existing property from an object, the result is undefined. Let’s compare the properties against undefined to determine the existence of the property.</p><pre>const user = {<br>  name: &quot;John&quot;,<br>};</pre><pre>console.log(user.name !== undefined); // true<br>console.log(user.nickName !== undefined); // false</pre><h3>49. What is an arguments object</h3><p>The arguments object is an Array-like object accessible inside functions that contains the values of the arguments passed to that function. For example, let’s see how to use arguments object inside sum function,</p><pre>function sum() {<br>  var total = 0;<br>  for (var i = 0, len = arguments.length; i &lt; len; ++i) {<br>    total += arguments[i];<br>  }<br>  return total;<br>}</pre><pre>sum(1, 2, 3); // returns 6</pre><p>Note: You can’t apply array methods on arguments object. But you can convert into a regular array as below.</p><pre>var argsArray = Array.prototype.slice.call(arguments);</pre><h3>50. How do you display the current date in javascript</h3><p>You can use new Date() to generate a new Date object containing the current date and time. For example, let&#39;s display the current date in mm/dd/yyyy</p><pre>var today = new Date();<br>var dd = String(today.getDate()).padStart(2, &quot;0&quot;);<br>var mm = String(today.getMonth() + 1).padStart(2, &quot;0&quot;); //January is 0!<br>var yyyy = today.getFullYear();</pre><pre>today = mm + &quot;/&quot; + dd + &quot;/&quot; + yyyy;<br>document.write(today);</pre><h3>51. How do you trim a string in javascript</h3><p>JavaScript provided a trim method on string types to trim any whitespaces present at the beginning or end of the string.</p><pre>&quot;  Hello World   &quot;.trim(); //Hello World</pre><p>If your browser(&lt;IE9) doesn’t support this method then you can use below polyfill.</p><pre>if (!String.prototype.trim) {<br>  (function () {<br>    // Make sure we trim BOM and NBSP<br>    var rtrim = /^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g;<br>    String.prototype.trim = function () {<br>      return this.replace(rtrim, &quot;&quot;);<br>    };<br>  })();<br>}</pre><h3>52. How do you add a key value pair in javascript</h3><p>There are two possible solutions to add new properties to an object. Let’s take a simple object to explain these solutions.</p><pre>var object = {<br>  key1: value1,<br>  key2: value2,<br>};</pre><ol><li>Using dot notation: This solution is useful when you know the name of the property</li></ol><pre>object.key3 = &quot;value3&quot;;</pre><p>2. Using square bracket notation: This solution is useful when the name of the property is dynamically determined.</p><pre>obj[&quot;key3&quot;] = &quot;value3&quot;;</pre><h3>53. What is a Regular Expression</h3><p>A regular expression is a sequence of characters that forms a search pattern. You can use this search pattern for searching data in a text. These can be used to perform all types of text search and text replace operations. Let’s see the syntax format now,</p><pre>/pattern/modifiers;</pre><p>For example, the regular expression or search pattern with case-insensitive username would be,</p><pre>/John/i;</pre><h3>54. Can I use reserved words as identifiers</h3><p>No, you cannot use the reserved words as variables, labels, object or function names. Let’s see one simple example,</p><pre>var else = &quot;hello&quot;; // Uncaught SyntaxError: Unexpected token else</pre><h3>55. How do you find user browser.</h3><p>To detect a user browser, we can make use of the global window object available in the browser. The window object contains a navigator object which can be accessed with or without referencing the window, because it can stand alone and is globally accessible.</p><pre>console.log(navigator.userAgent)</pre><h3>56. How do you make synchronous HTTP request</h3><p>Browsers provide an XMLHttpRequest object which can be used to make synchronous HTTP requests from JavaScript</p><pre>function httpGet(theUrl) {<br>  var xmlHttpReq = new XMLHttpRequest();<br>  xmlHttpReq.open(&quot;GET&quot;, theUrl, false); // false for synchronous request<br>  xmlHttpReq.send(null);<br>  return xmlHttpReq.responseText;<br>}</pre><h3>57. What are the ways to execute javascript after page load</h3><p>You can execute javascript after page load in many different ways,</p><ol><li>window.onload:</li></ol><pre>window.onload = function ...</pre><p>2. document.onload:</p><pre>document.onload = function ...</pre><p>3. body onload:</p><pre>&lt;body onload=&quot;script();&quot;&gt;</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=85f9e9ae114e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to Deploy ExpressJS & MongoDB application For Free? ]]></title>
            <link>https://medium.com/@malekrizwan08/how-to-deploy-expressjs-mongodb-application-for-free-ce032b29a0e1?source=rss-42577dde9901------2</link>
            <guid isPermaLink="false">https://medium.com/p/ce032b29a0e1</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[deployment]]></category>
            <category><![CDATA[expressjs]]></category>
            <category><![CDATA[mongodb]]></category>
            <category><![CDATA[rest-api]]></category>
            <dc:creator><![CDATA[Rizwan Malek]]></dc:creator>
            <pubDate>Mon, 14 Aug 2023 06:24:26 GMT</pubDate>
            <atom:updated>2023-08-14T06:24:26.126Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/784/0*K8v3-KGixwTn3tBQ" /><figcaption>Image Source: <a href="https://www.digitalocean.com/community/tutorials/building-for-production-web-applications-deploying">https://www.digitalocean.com/community/tutorials/building-for-production-web-applications-deploying</a></figcaption></figure><p>Hello readers and listeners 😊,</p><p>Let me support you in deploying ExpressJS Application with the MongoDB database.</p><p>First, we need to read any of the small ExpressJS Application With The Connection Of MongoDB.</p><p>Let me create a simple application 🤠</p><p>File =&gt; App.js</p><pre>const express = require(&quot;express&quot;);<br><br>require(&quot;./config/dotenv&quot;);<br>require(&quot;./utils/database&quot;);<br><br>const bodyParser = require(&quot;body-parser&quot;);<br><br>/* IMPORT ROUTES */<br>const todoRoutes = require(&quot;./routes/todo&quot;);<br><br>const app = express();<br>app.use(bodyParser.json());<br><br>/* ROUTES */<br>app.use(&quot;/todo&quot;, todoRoutes);<br><br>app.listen(process.env.SERVER_PORT || 8000, () =&gt; {<br>    console.log(&#39;Server Started PORT ==&gt; &#39;, process.env.SERVER_PORT);<br>});</pre><p>Note:- process.env.SERVER_PORT || 8000 In this line || 8000 Line is mandatory because the development server doesn’t have the env file that’s why we need to assign manually PORT.</p><p>File =&gt; Router.js</p><pre>const router = require(&quot;express&quot;).Router();<br><br>/* Controller Functions */<br>const {<br>    saveTodo,<br>    listTodo,<br>    deleteTodo<br>} = require(&quot;../controller/todo&quot;);<br><br>router.get(&quot;/list&quot;, listTodo);<br>router.post(&quot;/create&quot;, createTodoValidator, saveTodo);<br>router.put(&quot;/edit/:id&quot;, saveTodo);<br>router.delete(&quot;/delete/:id&quot;, deleteTodo);<br><br>module.exports = router;</pre><p>File =&gt; TodoController.js</p><pre>/* Model Import Statement */<br>const TodoModel = require(&quot;../model/todo&quot;);<br><br>/* Create &amp; Edit Function */<br>exports.saveTodo = async (req, res) =&gt; {<br>    const { id } = req.params;<br>    const { title, description } = req.body;<br>    try {<br>        if (id) {<br>            const editTodo = await TodoModel.findByIdAndUpdate(id, { title, description });<br>            if (!editTodo) return res.notFound(&quot;Todo is not found&quot;);<br>            return res.success(&quot;Todo has been updated successfully&quot;, { todo: editTodo });<br>        }<br>        const todo = new TodoModel({ title, description });<br>        const saveTodo = await todo.save();<br>        return res.success(&quot;Todo has been created successfully&quot;, { todo: saveTodo });<br>    } catch (e) {<br>        console.log(&#39;e ==&gt; &#39;, e);<br>    }<br>};<br><br>exports.listTodo = async (req, res) =&gt; {<br>    try {<br>        const list = await TodoModel.find();<br>        return res.success(null, list);<br>    } catch (e) {<br>        res.unauthorized();<br>    }<br>}<br><br>exports.deleteTodo = async (req, res) =&gt; {<br>    const { id } = req.params;<br>    try {<br>        const deleteTodo = await TodoModel.findByIdAndDelete(id);<br>        if (!deleteTodo) return res.notFound(&quot;Todo is not found&quot;);<br>        res.success(&quot;Todo has been deleted successfully&quot;);<br>    } catch (e) {<br>        console.log(&#39;e ==&gt; &#39;, e);<br>        res.unauthorized();<br>    }<br>}</pre><p>File =&gt; TodoModel.js</p><pre>const mongoose = require(&quot;mongoose&quot;);<br><br>const Schema = mongoose.Schema;<br><br>const todoSchema = Schema({<br>    title: {<br>        type: String,<br>        required: true<br>    },<br>    description: {<br>        type: String,<br>        required: true<br>    },<br>    addedBy: {<br>        type: Schema.ObjectId,<br>        ref: &#39;User&#39;<br>    }<br>});<br><br>module.exports = mongoose.model(&quot;Todo&quot;, todoSchema);</pre><p>File =&gt; Database.js</p><pre>const mongoose = require(&quot;mongoose&quot;);<br><br>mongoose.connect(`mongodb+srv://${process.env.MONGODB_DATABASE_USERNAME}:${@cluster0.emngez1.mongodb.net&quot;&gt;process.env.MONGODB_DATABASE_PASSWORD}@cluster0.emngez1.mongodb.net/learn-express`)<br>    .then((success) =&gt; {<br>        console.log(&#39;Database Successfully Connected&#39;);<br>    })<br>    .catch((error) =&gt; {<br>        console.log(&#39;error ==&gt; &#39;);<br>    });</pre><p>File =&gt; env</p><pre>SERVER_PORT = 8000<br>MONGODB_DATABASE_USERNAME = ****<br>MONGODB_DATABASE_PASSWORD = ****</pre><p>Note:- You Need To Create Env Variables On The Platform, This env is just for development.</p><p>You can deploy your own Express or Node application on the server :)</p><p>Let me guide what are the steps to deploy Express Application 🥷</p><p>Step 1</p><p>=&gt; You need to create or register yourself to the <a href="https://render.com/"><strong>render</strong></a> platform.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bCKnMQrd3xMtt1dMRfoo3Q.png" /><figcaption>Image Source: <a href="https://render.com/">https://render.com/</a></figcaption></figure><p>Step 2</p><p>=&gt; You need to select the web hosting options.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*n2-HAiNjhE8Y_Kw0S5fERA.png" /><figcaption>Image Source: <a href="https://dashboard.render.com/">https://dashboard.render.com/</a></figcaption></figure><p>In this option select the Web Services options. <strong>Marked as the yellow square in the above image.</strong></p><p>Step 3</p><p>=&gt; Connect your GitHub or GitLab account via the render Or you can paste the public repo URL with the text box below in the image.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MfJJGi9HKPnoqjc3GbPGNA.png" /></figure><p>Note:- I am connecting my GitHub account with the render. You can connect to Github or Gitlab or simply paste the public repository URL.</p><p>=&gt; You can see the list of repositories below in the image.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*uUcr8nnP-y4i4o73RZG9nA.png" /><figcaption>Image Source: <a href="https://render.com/">https://render.com/</a></figcaption></figure><p>Step 4</p><p>=&gt; You need to add basic configurations.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-mLy4PY_5kVz_qSWZyqesA.png" /><figcaption>Image Source: <a href="https://render.com/">https://render.com/</a></figcaption></figure><p>Note: You can select the hosting plan from the <a href="https://render.com/">render</a>. I have selected the Free plan from the render.</p><p>Step 5</p><p>=&gt; Select the branch from the listed repo.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*P7f8ALmPHkpSp-dsdKzgeg.png" /><figcaption>Image Source: <a href="https://render.com/">https://render.com/</a></figcaption></figure><p>=&gt; Write Root directory &amp; Run time</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MtcNv55jq5YfB0ZvPDrg7A.png" /><figcaption>Image Source: <a href="https://render.com/">https://render.com/</a></figcaption></figure><p>Note:- When you wished to deploy Expressjs Application please select the node from the runtime options.</p><p>Step 6</p><p>=&gt; Need to assign the <strong>Build command</strong> &amp; The Application <strong>Start command</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*l9VCVBBzAwycNDWsaUzZ3Q.png" /><figcaption>Image Source: <a href="https://render.com/">https://render.com/</a></figcaption></figure><p>Note:- You’re deploying the ExpressJS application with npm, kindly add the first <strong>npm install</strong> with ; (semicolon) , and then <strong>npm build</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*AzROSnoyuFzG5tSvKjwGDA.png" /><figcaption>Image Source: <a href="https://render.com/">https://render.com/</a></figcaption></figure><p>Now We are deployed the Express application 😍</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HlEA2h1IjCQwTUHlYlj-hA.png" /><figcaption>Image Source: <a href="https://render.com/">https://render.com/</a></figcaption></figure><p>You can test APIs on <a href="https://www.postman.com/">Postman</a> and any of the APIs environment testers or integrate APIs with the direct throw web front framework or mobile application.</p><p>Thank you for the reading, Keep sharing 🥰</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ce032b29a0e1" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Best & Simple Counter App Using ReactJS For Beginners]]></title>
            <link>https://medium.com/@malekrizwan08/best-simple-counter-app-using-reactjs-for-beginners-85a0e22b8ddf?source=rss-42577dde9901------2</link>
            <guid isPermaLink="false">https://medium.com/p/85a0e22b8ddf</guid>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[hooks]]></category>
            <category><![CDATA[javascrip]]></category>
            <category><![CDATA[learning]]></category>
            <category><![CDATA[reactjs]]></category>
            <dc:creator><![CDATA[Rizwan Malek]]></dc:creator>
            <pubDate>Tue, 20 Jun 2023 05:12:35 GMT</pubDate>
            <atom:updated>2023-06-20T05:12:35.737Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/212/1*s5Mbw5QfiKfHEpmBhJt3Fw.png" /><figcaption>Source: From The Author</figcaption></figure><p>Good day, readers and listeners! 🙃</p><p>Let’s construct a straightforward counter-react application.</p><p>You must be familiar with React hooks, such as useState, and have a basic understanding of React components in order to read this article.</p><h3>Code</h3><pre>import { useState } from &quot;react&quot;;<br><br>const componentStyle = { display: &quot;flex&quot;, justifyContent: &quot;center&quot;, gap: &quot;10px&quot;, marginTop: &quot;50px&quot; };<br>export default function CounterApp() {<br>    const [currentNumberCount, setCurrentNumberCount] = useState(0);<br>    return (&lt;&gt;<br>        &lt;div style={componentStyle}&gt;<br>            &lt;button onClick={() =&gt; setCurrentNumberCount(prev =&gt; prev !== 0 ? prev - 1 : 0)}&gt;-&lt;/button&gt;<br>            &lt;h5&gt;{currentNumberCount}&lt;/h5&gt;<br>            &lt;button onClick={() =&gt; setCurrentNumberCount(prev =&gt; prev + 1)}&gt;+&lt;/button&gt;<br>        &lt;/div&gt;<br>    &lt;/&gt;)<br>}</pre><h3>Explanation</h3><p>Just a basic import line here.</p><pre>import { useState } from &quot;react&quot;;</pre><p>Essential UI style, The w3school is a resource for style education. there is a link below</p><pre>const componentStyle = { display: &quot;flex&quot;, justifyContent: &quot;center&quot;, gap: &quot;10px&quot;, marginTop: &quot;50px&quot; };</pre><p><a href="https://www.w3schools.com/css/">W3Schools.com</a></p><p>The React hook for handling the counter state is this.</p><pre>const [currentNumberCount, setCurrentNumberCount] = useState(0);</pre><p>UI returned within the return statements.</p><pre>return (&lt;&gt;<br>        &lt;div style={componentStyle}&gt;<br>            &lt;button onClick={() =&gt; setCurrentNumberCount(prev =&gt; prev !== 0 ? prev - 1 : 0)}&gt;-&lt;/button&gt;<br>            &lt;h5&gt;{currentNumberCount}&lt;/h5&gt;<br>            &lt;button onClick={() =&gt; setCurrentNumberCount(prev =&gt; prev + 1)}&gt;+&lt;/button&gt;<br>        &lt;/div&gt;<br>    &lt;/&gt;)</pre><p>This function is called when the user presses the “-” Button to verify that the current value is not zero before increasing it by one.</p><pre>&lt;button onClick={() =&gt; setCurrentNumberCount(prev =&gt; prev !== 0 ? prev - 1 : 0)}&gt;-&lt;/button&gt;</pre><p>Call this function to raise the current number by 1 when the user presses the “+” button.</p><pre>&lt;button onClick={() =&gt; setCurrentNumberCount(prev =&gt; prev + 1)}&gt;+&lt;/button&gt;</pre><p>I appreciate you sharing this content 😇</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=85a0e22b8ddf" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to develop powerful authentication without using Redux In ReactJS?]]></title>
            <link>https://medium.com/@malekrizwan08/how-to-develop-powerful-authentication-without-using-redux-in-reactjs-42308d0118a7?source=rss-42577dde9901------2</link>
            <guid isPermaLink="false">https://medium.com/p/42308d0118a7</guid>
            <category><![CDATA[rest-api]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[context-api]]></category>
            <category><![CDATA[reactjs]]></category>
            <category><![CDATA[authentication]]></category>
            <dc:creator><![CDATA[Rizwan Malek]]></dc:creator>
            <pubDate>Fri, 02 Jun 2023 05:21:19 GMT</pubDate>
            <atom:updated>2023-06-05T09:04:54.589Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/628/0*tPdBF91cw8dQtSfR.png" /><figcaption>Image source: <a href="https://www.cisco.com/c/en/us/products/security/identity-services-engine/what-is-user-authentication-policy.html">https://www.cisco.com/c/en/us/products/security/identity-services-engine/what-is-user-authentication-policy.html</a></figcaption></figure><p>Hello readers and listeners 🙂</p><p>Let me introduce some of the concepts we will use in this tutorial</p><ol><li>useReducer Hook</li><li>Context API</li><li>Component</li><li>Events</li></ol><h3>1. useReducer Hook</h3><p>The useReducer hook is a React hook that allows you to manage the state in a more complex way than the useState hook. The useState hook is great for simple state management, but it can be difficult to use for more complex state logic. The useReducer hook allows you to define a reducer function that takes the current state and an action as input and returns the new state. This makes it easy to manage complex state logic, and it can also improve performance.</p><h4>How to Use the useReducer Hook</h4><p>To use the useReducer hook, you first need to define a reducer function. The reducer function takes the current state and an action as input and returns the new state. The action object can be used to pass data to the reducer function.</p><p>Once you have defined the reducer function, you can use the useReducer hook to get the current state and a dispatch function. The dispatch function can be used to update the state by calling it an action object.</p><h4>The syntax for the useReducer hook in ReactJS:</h4><pre>const [state, dispatch] = useReducer(reducer, initialState);</pre><ul><li>reducer is a function that takes the current state and an action as input, and returns the new state.</li><li>initialState is the initial state of the component.</li><li>state is a reference to the current state of the component.</li><li>dispatch is a function that is used to send actions to the reducer function.</li></ul><h4>Example of how to use the useReducer hook:</h4><pre>import { useReducer } from &quot;react&quot;;<br><br>const initialState = {<br>    dynamicData: null,<br>    isLoading: false,<br>    error: null,<br>}<br>const reducer = (state = initialState, { type, payload }) =&gt; {<br>    switch (type) {<br>        case &quot;GET_DATA_PENDING&quot;:<br>            return { ...state, isLoading: true, };<br>        case &quot;GET_DATA_SUCCESS&quot;:<br>            return { ...state, dynamicData: payload, isLoading: false, };<br>        case &quot;GET_DATA_SUCCESS&quot;:<br>            return { ...state, error: payload, isLoading: false, };<br>        default:<br>            return state;<br>    }<br><br>}<br>export default function App() {<br>    const [state, dispatch] = useReducer(reducer, initialState);<br><br>    const handleGetDynamicData = () =&gt; {<br>        try {<br>            dispatch({ type: &quot;GET_DATA_PENDING&quot; });<br>            // DO API Calling<br>            dispatch({ type: &quot;GET_DATA_SUCCESS&quot;, payload: { /* Dynamic Getted Data */ } });<br>        } catch (error) {<br>            dispatch({ type: &quot;GET_DATA_FAILED&quot;, payload: error });<br>        }<br>    }<br>    return (<br>        &lt;div&gt;<br>            &lt;button onClick={handleGetDynamicData}&gt;GET DYNAMIC DATA&lt;/button&gt;<br>        &lt;/div&gt;<br>    );<br>}<br><br><br><br></pre><p>If you want to learn more about useReducer, kindly follow this official documentation link.</p><p><a href="https://react.dev/reference/react/useReducer#usereducer">useReducer - React</a></p><h3>2. Context API</h3><p>Context API is a React feature that allows you to share data between components without having to pass props down manually at every level. This can make your code more reusable and easier to maintain.</p><p>Context API is made up of two main components:</p><ul><li>Context Provider: This component creates the context and provides access to its data.</li><li>Context Consumer: This component consumes the context and its data.</li></ul><p>How to Use Context API</p><p>To use Context API, you first need to create a context provider. This can be done by creating a component that extends the ContextProvider class and providing the context object as a prop.</p><pre>import React, { Context, useContext } from &#39;react&#39;;<br><br>const MyContext = React.createContext(null);<br><br>const MyContextProvider = ({ children }) =&gt; {<br>  const [data, setData] = useState(null);<br><br>  return (<br>    &lt;MyContext.Provider value={data}&gt;<br>      {children}<br>    &lt;/MyContext.Provider&gt;<br>  );<br>};<br><br>export { MyContext, MyContextProvider };</pre><p>Once you have created a context provider, you can use it to provide access to its data in other components. To do this, you need to wrap the component that needs access to the data in a ContextConsumer component.</p><pre>import React, { useContext } from &#39;react&#39;;<br>import { MyContext } from &#39;./MyContext&#39;;<br><br>const MyComponent = () =&gt; {<br>  const data = useContext(MyContext);<br><br>  return &lt;div&gt;The data is {data}&lt;/div&gt;;<br>};<br><br>export default MyComponent;</pre><p>Benefits of Using Context API</p><p>There are several benefits to using Context API in your React applications. Here are a few of the most important ones:</p><ul><li>Reusability: Context API can make your code more reusable by allowing you to share data between components without having to pass props down manually. This can make your code easier to maintain and update.</li><li>Performance: Context API can improve the performance of your application by reducing the number of props that need to be passed down the component tree. This can be especially beneficial in large applications with a deep component tree.</li><li>Simplicity: Context API is a simple and easy-to-use API that can be quickly learned and implemented. This makes it a good choice for developers of all skill levels.</li></ul><p>If you want to learn more about Context API, kindly follow this official documentation link.</p><p><a href="https://react.dev/reference/react/createContext">createContext - React</a></p><h3>3. Component</h3><p>A React component is a reusable piece of code that is used to render HTML elements. Components are the building blocks of React applications, and they can be used to create complex user interfaces.</p><h4>How do React Components Work?</h4><p>React components work by using a render function to return the HTML elements that should be displayed. The render function is called whenever the component is mounted or updated.</p><h4>What are the Benefits of Using React Components?</h4><p>There are many benefits to using React components, including:</p><ul><li>Reusability: Components can be reused throughout an application, which can help to reduce code duplication and improve code maintainability.</li><li>Scalability: Components can be composed to create complex user interfaces, which can help to make applications more maintainable and easier to test.</li><li>Performance: Components can be optimized for performance, which can help to improve the overall performance of an application.</li></ul><h4>Where can I learn more about React Components?</h4><p>There are many resources available to help you learn more about React components. Here are a few of the most popular resources:</p><ul><li>The React documentation: The React documentation provides a comprehensive overview of React components, including how to create, use, and extend them.</li><li>The React tutorial: The React tutorial provides a step-by-step guide to creating a React application using components.</li><li>The React community: The React community is a great resource for learning more about React components. There are many online forums and chat rooms where you can ask questions and get help from other React developers.</li></ul><p>Example of a simple React component:</p><pre>function Welcome(props) {<br>  return (<br>    &lt;h1&gt;Hello, {props.name}&lt;/h1&gt;<br>  );<br>}</pre><p>If you want to learn more about React Component, kindly follow this official documentation link.</p><p><a href="https://react.dev/reference/react/Component">Component - React</a></p><h3>4. Events</h3><h4>Events in React JS</h4><p>When a user interacts with a React component, such as clicking on an element or typing in a text field, an event is triggered. Events are handled by event handlers, which are functions that are called when an event is triggered. Event handlers can be attached to any React component, and they can be used to perform any action, such as changing the state of the component, updating the DOM, or making an API call.</p><h4>Handling Events in React JS</h4><p>There are two ways to handle events in React JS:</p><ul><li>Directly: This is the most common way to handle events. To handle an event directly, you attach an event handler to the component using the onClick prop. The event handler function will be called when the event is triggered.</li><li>Through a higher-order component: A higher-order component is a function that takes a component as its input and returns a new component. Higher-order components can be used to handle events in a more centralized way.</li></ul><h4>Synthetic Events</h4><p>React JS uses synthetic events instead of native DOM events. Synthetic events are objects that contain information about the event, such as the type of event, the target element, and the event’s properties. Synthetic events are used to ensure that React components work consistently across different browsers.</p><h4>Event Propagation</h4><p>When an event is triggered, it bubbles up the DOM tree. This means that the event handler for the closest ancestor of the target element will be called first, followed by the event handler for the next closest ancestor, and so on. Event propagation can be stopped by calling the stopPropagation() method on the event object.</p><h4>Event Bubbling</h4><p>Event bubbling is the opposite of event propagation. When an event is triggered, it bubbles down the DOM tree. This means that the event handler for the target element will be called last, followed by the event handler for its parent element, and so on. Event bubbling can be stopped by calling the preventDefault() method on the event object.</p><pre>&lt;button onClick={handleClick}&gt;Click Me!&lt;/button&gt;<br><br>function handleClick() {<br>  // Do something when the button is clicked<br>}</pre><p>When the user clicks on the button, the handleClick function will be called. This function can then be used to perform any desired action, such as changing the state of the application or displaying a message.</p><p>If you want to learn more about Events for ReactJS, kindly follow this official documentation link.</p><p><a href="https://react.dev/learn/responding-to-events">Responding to Events - React</a></p><p>Now we are learned about context API and useReducer hook and more.</p><p>Time to develop a powerful authentication system without using redux.</p><p>So, Let’s start guys 😊…</p><h4>First we need to defined initial state or value for context, Let me show you</h4><pre>const initialState = {<br>    token: localStorage.getItem(&quot;token&quot;) ? localStorage.getItem(&quot;token&quot;) : null,<br>    isLoading: false,<br>    message: null,<br>    error: null,<br>};</pre><blockquote>You can declare initial state as per your requirements.</blockquote><p>The key concept is that this code defines the initial state of a Context API. The state object contains four properties:</p><ul><li>token: This property stores the user&#39;s authentication token. If the user is not authenticated, this property will be null.</li><li>isLoading: This property indicates whether the application is currently loading data.</li><li>message: This property stores a message that is displayed to the user.</li><li>error: This property stores an error message that is displayed to the user.</li></ul><p>The initial state of the application is determined by the values of these properties. For example, if the user is authenticated, the token property will be set to the user&#39;s authentication token. If the application is not loading data, the isLoading property will be set to false.</p><p>The initial state of the application is used to initialize the application’s UI. For example, if the token property is set to a non-null value, the application will display the user&#39;s name and profile picture. If the isLoading property is set to true, the application will display a loading indicator.</p><h4>Second thing we need to create context instance</h4><pre>const authContext = createContext(initialState);</pre><p>This code creates a React context called AuthContext. A context is a way to share data between different components in a React application. The createContext function takes two arguments: the name of the context and the initial state. The initial state is the data that will be available to components that use the context when they are first rendered</p><p>You can give any name to instance</p><h4>Third thing we need to create reducer for useReducer hook</h4><pre>const setReducerState = (state = initialState, { type, payload }) =&gt; {<br>    switch (type) {<br>        case &quot;LOGIN_PENDING&quot;:<br>            return { ...state, isLoading: true }<br>        case &quot;LOGIN_SUCCESS&quot;:<br>            localStorage.setItem(&quot;token&quot;, payload.token);<br>            return {<br>                ...state,<br>                isLoading: false,<br>                token: payload.token,<br>                message: payload.message<br>            }<br>        case &quot;LOGIN_FAILED&quot;:<br>            return { ...state, isLoading: false, error: payload }<br>        case &quot;LOGOUT&quot;:<br>            localStorage.removeItem(&quot;token&quot;);<br>            return { ...state, token: null, message: &quot;Logout successfully !&quot;, error: null }<br>        default: return state;<br>    }<br>}</pre><p>The setReducerState function is a reducer function that is used to update the state of the application. The function takes two arguments:</p><ul><li>state: The current state of the application.</li><li>action: An object that contains information about the event that triggered the state update. (Type, Payload)</li></ul><p>The function uses a switch statement to determine how to update the state based on the type of event. The following are the possible events and their corresponding state updates:</p><ul><li>LOGIN_PENDING: The application is in the process of logging in. The state is updated to show that the application is loading.</li><li>LOGIN_SUCCESS: The user has successfully logged in. The state is updated to show that the user is logged in, and the token is stored in local storage.</li><li>LOGIN_FAILED: The user has failed to log in. The state is updated to show that the user is not logged in, and the error message is displayed.</li><li>LOGOUT: The user has logged out. The token is removed from local storage, and the state is updated to show that the user is not logged in.</li></ul><h4>The fourth thing we need to create one component to manage and update the context at single place</h4><pre>const Authentication = ({<br>    children<br>}) =&gt; {    <br>    return (&lt;&gt;<br>        &lt;authContext.Provider value={{<br>            /* Values */<br>        }}&gt;<br>            {children}<br>        &lt;/authContext.Provider&gt;<br>    &lt;/&gt;)<br>};</pre><ul><li>This code defines a component called Authentication.</li><li>The Authentication the component takes a single prop called children.</li><li>The Authentication the component renders a authContext.Provider component.</li><li>The authContext.Provider component has a value prop that is an object with the following values:</li><li>The Authentication the component renders the children prop inside the authContext.Provider component.</li><li>This allows the Authentication component to access the user&#39;s authentication status and data.</li></ul><h4>Now time to dispatch actions</h4><pre>const Authentication = ({<br>    children<br>}) =&gt; {<br>    const [values, dispatch] = useReducer(setReducerState, initialState);<br>    const handleLogin = async (payload) =&gt; {<br>        try {<br>            dispatch({ type: &quot;LOGIN_PENDING&quot; });<br>            const response = await fetch({<br>                url: /* Login URL */,<br>                method: &quot;post&quot;,<br>                body: payload<br>            });<br>            const convertedData = await response.json();<br>            dispatch({<br>                type: &quot;LOGIN_SUCCESS&quot;,<br>                payload: {<br>                    token: convertedData.token,<br>                    message: convertedData.message,<br>                }<br>            });<br>        } catch (error) {<br>            dispatch({ type: &quot;LOGIN_FAILED&quot; });<br>        }<br>    }<br>    const handleLogout = async (payload) =&gt; {<br>        dispatch({ type: &quot;LOGOUT&quot; });<br>    }<br>    return (&lt;&gt;<br>        &lt;authContext.Provider value={{<br>            state: values,<br>            handleLogin,<br>            handleLogout<br>        }}&gt;<br>            {children}<br>        &lt;/authContext.Provider&gt;<br>    &lt;/&gt;)<br>};<br>export default Authentication;</pre><p>The Authentication component is responsible for handling authentication for a React application. It uses the useReducer hook to manage the application&#39;s authentication state, and provides methods for logging in and logging out.</p><p>The handleLogin method makes an asynchronous request to the /auth/login endpoint to log in the user. If the request is successful, the method dispatches a LOGIN_SUCCESS action with the user&#39;s token and message. If the request fails, the method dispatches a LOGIN_FAILED action.</p><p>The handleLogout method makes an asynchronous request to the /auth/logout endpoint to log out the user. If the request is successful, the method dispatches a LOGOUT action.</p><p>The Authentication component uses the authContext to provide the application&#39;s authentication state to its children. The authContext is a provider that exposes the following properties:</p><ul><li>state: The application&#39;s authentication state.</li><li>handleLogin: A method for logging in the user.</li><li>handleLogout: A method for logging out the user.</li></ul><p>The Authentication component should be used as the root component of a React application that requires authentication.</p><h4>Now We can able to implement context API in root component</h4><pre>import &#39;./App.css&#39;;<br>import Authentication from &#39;./Authentication&#39;;<br><br>function App() {<br>  return (<br>    &lt;&gt;<br>      &lt;Authentication&gt;<br>        &lt;h1&gt;THIS DATA IS RENDERED&lt;/h1&gt;<br>      &lt;/Authentication&gt;<br>    &lt;/&gt;<br>  );<br>}<br><br>export default App;</pre><p>The code above imports the Authentication component from the ./Authentication file and renders it inside the App component. The Authentication component is responsible for handling authentication for a React application. It uses the useReducer hook to manage the application&#39;s authentication state, and provides methods for logging in and logging out.</p><p>The App component renders the Authentication component and a h1 element with the text &quot;THIS DATA IS RENDERED&quot;. The Authentication component will only render the h1 element if the user is logged in.</p><h4>Whole code in one code snippet</h4><pre>import { createContext, useReducer } from &quot;react&quot;;<br><br>const initialState = {<br>    token: localStorage.getItem(&quot;token&quot;) ? localStorage.getItem(&quot;token&quot;) : null,<br>    isLoading: false,<br>    message: null,<br>    error: null,<br>};<br><br>const authContext = createContext(initialState);<br><br>const setReducerState = (state = initialState, { type, payload }) =&gt; {<br>    switch (type) {<br>        case &quot;LOGIN_PENDING&quot;:<br>            return { ...state, isLoading: true }<br>        case &quot;LOGIN_SUCCESS&quot;:<br>            localStorage.setItem(&quot;token&quot;, payload.token);<br>            return {<br>                ...state,<br>                isLoading: false,<br>                token: payload.token,<br>                message: payload.message<br>            }<br>        case &quot;LOGIN_FAILED&quot;:<br>            return { ...state, isLoading: false, error: payload }<br>        case &quot;LOGOUT&quot;:<br>            localStorage.removeItem(&quot;token&quot;);<br>            return { ...state, token: null, message: &quot;Logout successfully !&quot;, error: null }<br>        default: return state;<br>    }<br>}<br><br>const Authentication = ({<br>    children<br>}) =&gt; {<br>    const [values, dispatch] = useReducer(setReducerState, initialState);<br>    const handleLogin = async (payload) =&gt; {<br>        try {<br>            dispatch({ type: &quot;LOGIN_PENDING&quot; });<br>            const response = await fetch({<br>                url: &quot;http://192.168.100.86:3000/auth/login&quot;,<br>                method: &quot;post&quot;,<br>                body: payload<br>            });<br>            const convertedData = await response.json();<br>            dispatch({<br>                type: &quot;LOGIN_SUCCESS&quot;,<br>                payload: {<br>                    token: convertedData.token,<br>                    message: convertedData.message,<br>                }<br>            });<br>        } catch (error) {<br>            dispatch({ type: &quot;LOGIN_FAILED&quot; });<br>        }<br>    }<br>    const handleLogout = async (payload) =&gt; {<br>        dispatch({ type: &quot;LOGOUT&quot; });<br>    }<br>    return (&lt;&gt;<br>        &lt;authContext.Provider value={{<br>            state: values,<br>            handleLogin,<br>            handleLogout<br>        }}&gt;<br>            {children}<br>        &lt;/authContext.Provider&gt;<br>    &lt;/&gt;)<br>};<br>export default Authentication;</pre><p>I hope this will help you 😇</p><p>Resources for learning ReactJS</p><p><a href="https://react.dev/">React</a></p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FSqcY0GlETPk%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DSqcY0GlETPk&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FSqcY0GlETPk%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/3972cf578381678623673b51ca82b129/href">https://medium.com/media/3972cf578381678623673b51ca82b129/href</a></iframe><ul><li><a href="https://www.w3schools.com/REACT/DEFAULT.ASP">React Tutorial</a></li><li><a href="https://www.geeksforgeeks.org/reactjs-tutorials/">ReactJS Tutorials - GeeksforGeeks</a></li></ul><p>Thank you so much guys 🙂, Keep sharing 🙃</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=42308d0118a7" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How Programmers Can Use ChatGPT and Google Bard]]></title>
            <link>https://medium.com/@malekrizwan08/how-programmers-can-use-chatgpt-and-google-bard-69dde71ef077?source=rss-42577dde9901------2</link>
            <guid isPermaLink="false">https://medium.com/p/69dde71ef077</guid>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[naturallanguageprocessing]]></category>
            <category><![CDATA[chatgpt]]></category>
            <category><![CDATA[google-bard]]></category>
            <category><![CDATA[future-of-technology]]></category>
            <dc:creator><![CDATA[Rizwan Malek]]></dc:creator>
            <pubDate>Fri, 19 May 2023 06:34:12 GMT</pubDate>
            <atom:updated>2023-05-19T06:34:12.642Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*r828SAKgvSDjURfF" /><figcaption>Source: <a href="https://zapier.com/blog/chatgpt-vs-bard/">https://zapier.com/blog/chatgpt-vs-bard/</a></figcaption></figure><p>Hello readers and listeners :)</p><p>ChatGPT and Google Bard are two large language models (LLMs) that have been trained on massive datasets of text and code. This makes them capable of generating text, translating languages, writing different kinds of creative content, and answering your questions in an informative way.</p><p>For programmers, ChatGPT and Google Bard can be used for a variety of tasks, including:</p><h3>Generating code</h3><p>ChatGPT and Google Bard can be used to generate code, which can be helpful for tasks such as writing unit tests, generating documentation, and creating prototypes.</p><p>Code generation is the process of automatically creating computer source code from a higher-level representation, such as a design specification, a graphical model, or a natural language description. Code generators can be used to automate the development of software, to improve the quality of code, and to make code more portable.</p><p>Here are some of the benefits of using code generation:</p><ul><li>Increased productivity: Code generators can automate the repetitive tasks of software development, freeing up developers to focus on more creative and strategic work.</li><li>Improved quality: Code generators can help to ensure that code is consistent, well-formatted, and error-free.</li><li>Increased portability: Code generators can help to make code more portable across different platforms and programming languages.</li></ul><p>Code generators can be used to generate code for a wide variety of applications, including:</p><ul><li>Web applications</li><li>Mobile applications</li><li>Desktop applications</li><li>Enterprise applications</li><li>Scientific applications</li></ul><h3>Testing code</h3><p>ChatGPT and Google Bard can be used to test code by generating test cases. This can be helpful for finding bugs and ensuring that the code is working as intended.</p><p>Code testing is the process of executing code with the intent of finding errors. It is an essential part of the software development process, as it helps to ensure that the code is working as intended. There are many different types of code testing, including unit testing, integration testing, system testing, and acceptance testing.</p><p>Artificial intelligence (AI) is rapidly changing the software testing landscape. AI-powered tools can help testers automate repetitive tasks, identify potential bugs, and improve the overall quality of software.</p><p>Here are some of the ways AI can help with software testing:</p><ul><li>Automating repetitive tasks: AI can automate many of the manual tasks that testers typically perform, such as data entry, test case execution, and bug reporting. This frees up testers to focus on more complex tasks, such as designing and executing exploratory tests.</li><li>Identifying potential bugs: AI can be used to analyze code and identify potential bugs. This can be done by looking for patterns in the code, or by using machine learning to identify code that is similar to code that has been known to contain bugs.</li><li>Improving the overall quality of software: AI can be used to improve the overall quality of software by helping testers to find and fix bugs earlier in the development process. This can save time and money, and it can help to ensure that software is released with fewer defects.</li></ul><p>Overall, AI has the potential to revolutionize software testing. By automating repetitive tasks, identifying potential bugs, and improving the overall quality of software, AI can help testers to be more efficient and effective.</p><p>Here are some specific examples of how AI is being used in software testing:</p><ul><li>Test impact analysis: AI can be used to analyze the impact of changes to code on existing tests. This can help to ensure that tests are still valid after changes have been made, and it can help to prevent regressions.</li><li>Data-driven testing: AI can be used to generate test data based on real-world data. This can help to ensure that tests are more comprehensive and that they cover a wider range of potential scenarios.</li><li>Exploratory testing: AI can be used to help testers with exploratory testing. This is a type of testing where testers try to find bugs by exploring the software in a free-form way. AI can help testers to identify potential areas of concern and to generate test cases based on their findings.</li></ul><h3>Writing documentation</h3><p>ChatGPT and Google Bard can be used to write documentation for code. This can be helpful for making code more readable and understandable for other developers.</p><p>AI can help with writing documentation in a number of ways. For example, AI can be used to:</p><ul><li>Generate text automatically, which can save time and effort.</li><li>Improve the quality of documentation by catching errors and making suggestions for improvement.</li><li>Make documentation more accessible to users by providing different formats and translations.</li><li>Personalize documentation to the needs of individual users.</li><li>Track the usage of documentation to identify areas that need improvement.</li></ul><p>Overall, AI can be a valuable tool for improving the process of writing and maintaining documentation.</p><p>Here are some specific examples of how AI is being used to help with documentation:</p><ul><li>Google AI has developed an AI tool called Bard that can generate text, translate languages, write different kinds of creative content, and answer your questions in an informative way. Bard can be used to help with documentation by generating text automatically, improving the quality of documentation, and making documentation more accessible to users.</li><li>GitHub Copilot is an AI-powered coding assistant that can help developers write code more quickly and efficiently. Copilot can also be used to help with documentation by generating documentation for code automatically.</li><li>QuillBot is an AI writing tool that can help you rewrite entire sentences or paragraphs with just a few clicks. QuillBot can be used to help with documentation by improving the quality of documentation and making it more concise.</li></ul><h3>Creating prototypes</h3><p>ChatGPT and Google Bard can be used to create prototypes of new features or applications. This can be helpful for testing ideas and getting feedback from users before investing in development.</p><p>Artificial intelligence (AI) can help in creating prototypes in a number of ways.</p><ul><li>AI can help to speed up the prototyping process. AI can automate many of the tasks involved in prototyping, such as generating designs, testing prototypes, and collecting feedback. This can free up designers and engineers to focus on more creative and strategic tasks.</li><li>AI can help to improve the quality of prototypes. AI can be used to analyze data and identify potential problems with prototypes. This can help to ensure that prototypes are more reliable and effective.</li><li>AI can help to reduce the cost of prototyping. AI can be used to automate many of the tasks involved in prototyping, which can help to reduce the overall cost of the process.</li></ul><p>Overall, AI can be a valuable tool for creating prototypes. It can help to speed up the process, improve the quality of prototypes, and reduce the cost.</p><p>Here are some specific examples of how AI is being used to create prototypes:</p><ul><li>In the automotive industry, AI is being used to design and test new car parts. AI can be used to analyze data from crash tests and simulations to identify potential weaknesses in car parts. This information can then be used to design new parts that are stronger and more durable.</li><li>In the healthcare industry, AI is being used to develop new medical devices. AI can be used to analyze data from medical images and scans to identify potential problems. This information can then be used to develop new devices that can diagnose and treat diseases more effectively.</li><li>In the manufacturing industry, AI is being used to create new products. AI can be used to analyze data from customer surveys and feedback to identify potential new products. This information can then be used to design and develop new products that meet the needs of customers.</li></ul><h3>Answering questions</h3><p>ChatGPT and Google Bard can be used to answer questions about code. This can be helpful for debugging code, learning new programming languages, and getting help with programming tasks.</p><p>In addition to these specific tasks, ChatGPT and Google Bard can also be used for a variety of other creative and educational purposes. For example, they can be used to generate poems, stories, and scripts. They can also be used to teach students about different subjects, such as history, science, and math.</p><p>Overall, ChatGPT and Google Bard are powerful tools that can be used by programmers for a variety of tasks. They are still under development, but they have the potential to revolutionize the way that programmers work.</p><p>Artificial intelligence (AI) can help answer questions in a number of ways. One way is by using natural language processing (NLP) to extract the meaning of the question. NLP is a field of computer science that deals with the interaction between computers and human (natural) languages. Once the meaning of the question is extracted, AI can then use its knowledge of the world to find the answer.</p><p>Another way that AI can help answer questions is by using machine learning (ML). ML is a field of computer science that gives computers the ability to learn without being explicitly programmed. ML can be used to train AI models to answer questions by providing them with examples of questions and answers. Once the model is trained, it can be used to answer new questions.</p><p>AI is still under development, but it has already shown promise in helping answer questions. As AI continues to develop, it is likely that it will become even more effective at answering questions. This could have a number of benefits, such as making it easier for people to find information, improving customer service, and helping to automate tasks.</p><p>Here are some specific examples of how AI is being used to answer questions:</p><ul><li>Google Search uses AI to answer questions that are asked in natural language.</li><li>Amazon Alexa uses AI to answer questions about the weather, traffic, and other information.</li><li>Apple Siri uses AI to answer questions about the user’s schedule, contacts, and other information.</li><li>Many businesses are using AI to answer customer questions in real-time.</li><li>AI is being used to automate tasks such as summarizing documents and answering questions about data.</li></ul><h3>Be specific in your requests</h3><p>The more specific you are in your requests, the better the results will be. For example, instead of asking “Write me a poem,” ask “Write me a poem about a cat.”</p><p>Artificial intelligence (AI) can help you be more specific in your requests by providing you with more information and options. For example, if you ask an AI assistant to “find me a restaurant,” it might return a list of restaurants that are nearby. However, if you ask it to “find me a restaurant that serves Italian food and is open late,” it will be able to narrow down the results and provide you with a more specific list of options.</p><p>AI can also help you be more specific by understanding your context. For example, if you are in a meeting and you ask your AI assistant to “send an email,” it will know that you are referring to the email that you were just working on. This can help you avoid making mistakes and wasting time.</p><p>Overall, AI can be a valuable tool for helping you be more specific in your requests. By providing you with more information and options, AI can help you get the results that you want more quickly and easily.</p><p>Here are some tips for being more specific in your requests to AI:</p><ul><li>Use keywords and phrases that are specific to what you are looking for.</li><li>Provide as much context as possible.</li><li>Be willing to provide feedback.</li><li>Ask follow-up questions.</li></ul><h3>Use natural language</h3><p>ChatGPT and Google Bard are trained in natural language, so it is best to use natural language when making requests. For example, instead of saying “Generate code for a login form,” say “Write me a login form in Python.”</p><p>AI helps us use natural language:</p><ul><li>Machine Translation: AI can be used to translate text from one language to another. This is a very useful tool for people who need to communicate with people who speak other languages.</li><li>Question Answering: AI can be used to answer questions posed in natural language. This is a very useful tool for students, researchers, and anyone else who needs to find information quickly.</li><li>Sentiment Analysis: AI can be used to analyze the sentiment of the text. This is a very useful tool for businesses that want to understand how their customers feel about their products or services.</li><li>Chatbots: AI can be used to create chatbots that can interact with people in natural language. This is a very useful tool for businesses that want to provide customer service 24/7.</li><li>Text Summarization: AI can be used to summarize the text in a concise and informative way. This is a very useful tool for students, researchers, and anyone else who needs to quickly understand the main points of a long text.</li></ul><p>These are just a few examples of how AI is helping us use natural language. As AI technology continues to develop, we can expect to see even more ways to use AI to interact with language in new and innovative ways.</p><p>Here are some additional details about each of these applications:</p><ul><li>Machine Translation: Machine translation is a type of natural language processing that allows computers to translate text from one language to another. This is a very useful tool for people who need to communicate with people who speak other languages. For example, a business that wants to expand into a new market can use machine translation to translate its website and marketing materials into the language of that market.</li><li>Question Answering: Question answering is a type of natural language processing that allows computers to answer questions posed in natural language. This is a very useful tool for students, researchers, and anyone else who needs to find information quickly. For example, a student can use question-answering to find information for a research paper or a researcher can use question-answering to find information for a new study.</li><li>Sentiment Analysis: Sentiment analysis is a type of natural language processing that allows computers to analyze the sentiment of the text. This is a very useful tool for businesses that want to understand how their customers feel about their products or services. For example, a business can use sentiment analysis to track customer satisfaction or to identify potential problems with its products or services.</li><li>Chatbots: Chatbots are computer programs that can simulate conversations with human users. Chatbots are often used in customer service applications, where they can answer questions and provide support to customers 24/7. Chatbots can also be used for other purposes, such as providing information or entertainment.</li><li>Text Summarization: Text summarization is a type of natural language processing that allows computers to summarize text in a concise and informative way. This is a very useful tool for students, researchers, and anyone else who needs to quickly understand the main points of a long text. For example, a student can use text summarization to quickly get the gist of a long article or a researcher can use text summarization to quickly review a large body of research.</li></ul><h3>Provide examples</h3><p>If you can provide examples of the kind of output you are looking for, ChatGPT and Google Bard will be more likely to generate the desired results. For example, if you are asking ChatGPT to write a poem about a cat, you could provide an example of a poem about a cat that you like.</p><p>Artificial intelligence (AI) is a branch of computer science that deals with the creation of intelligent agents, which are systems that can reason, learn, and act autonomously. AI has the potential to help people in a variety of ways, including:</p><ul><li>Automating tasks. AI can be used to automate tasks that are currently done by humans, such as customer service, data entry, and medical diagnosis. This can free up human workers to focus on more creative and strategic tasks.</li><li>Making predictions. AI can be used to make predictions about future events, such as the weather, the stock market, and the spread of disease. This information can be used to make better decisions and to avoid risks.</li><li>Personalizing experiences. AI can be used to personalize experiences for individuals, such as recommending products, suggesting movies, and tailoring newsfeeds. This can make people’s lives more convenient and enjoyable.</li><li>Solving complex problems. AI can be used to solve complex problems that are beyond the capabilities of humans, such as designing new drugs, developing self-driving cars, and fighting climate change.</li></ul><p>Here are some examples of how AI is currently being used to help people:</p><ul><li>Customer service. AI-powered chatbots are being used by businesses to answer customer questions and resolve issues 24/7. This can free up human customer service representatives to focus on more complex tasks.</li><li>Data entry. AI-powered tools are being used to automate data entry tasks, such as extracting information from documents and entering it into databases. This can save businesses time and money.</li><li>Medical diagnosis. AI-powered tools are being used to help doctors diagnose diseases more accurately and quickly. This can lead to earlier treatment and better outcomes for patients.</li><li>Personalized recommendations. AI-powered tools are being used to recommend products, movies, and other content to individuals based on their interests. This can help people find the things they are looking for more quickly and easily.</li><li>Self-driving cars. AI is being used to develop self-driving cars that can navigate roads and avoid obstacles without human input. This has the potential to revolutionize transportation and make roads safer.</li></ul><p>Thanks :)</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=69dde71ef077" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Benefits of using ReactJS]]></title>
            <link>https://medium.com/@malekrizwan08/benefits-of-using-reactjs-70c583e4c37d?source=rss-42577dde9901------2</link>
            <guid isPermaLink="false">https://medium.com/p/70c583e4c37d</guid>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[frontend]]></category>
            <category><![CDATA[reactjs]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[javascript]]></category>
            <dc:creator><![CDATA[Rizwan Malek]]></dc:creator>
            <pubDate>Fri, 19 May 2023 06:06:03 GMT</pubDate>
            <atom:updated>2023-05-19T06:06:03.281Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/512/1*m50l56cHyMEzcXVcbSwXGw.png" /><figcaption>Source: <a href="https://reactjs.org/">https://reactjs.org/</a></figcaption></figure><p>Hello reader and listeners</p><p>ReactJS is a JavaScript library for building user interfaces. It is one of the most popular front-end frameworks in use today and for good reason. ReactJS offers a number of benefits that make it a great choice for building high-quality, user-friendly web applications.</p><p>1. Performance</p><p>One of the biggest benefits of ReactJS is its performance. ReactJS uses a virtual DOM to track changes to the user interface. This means that ReactJS only updates the actual DOM when changes are needed, which can lead to significant performance improvements.</p><p>2. Flexibility</p><p>ReactJS is a very flexible framework. It can be used to build a wide variety of web applications, from simple single-page applications to complex enterprise applications. ReactJS is also highly scalable, making it a good choice for large and complex projects.</p><p>3. Reusability</p><p>ReactJS components are highly reusable. This means that developers can create components that can be used in multiple applications. This can save a lot of time and effort, and it can also help to ensure that the code is consistent across applications.</p><p>4. Developer tools</p><p>ReactJS comes with a number of powerful developer tools. These tools can help developers to debug their code, profile their applications, and test their components. This can help to improve the quality of the code and the overall user experience.</p><p>5. Community support</p><p>ReactJS has a large and active community of developers. This community provides a wealth of resources, including tutorials, documentation, and support forums. This can be a great resource for developers who are new to ReactJS, or who need help with a particular problem.</p><p>Overall, ReactJS is a powerful and versatile framework that offers a number of benefits for building web applications. If you are looking for a framework that is performant, flexible, reusable, and well-supported, then ReactJS is a great choice.</p><p>Here are some additional benefits of using ReactJS:</p><ul><li>SEO-friendly: ReactJS is SEO-friendly, which means that your web pages will rank well in search engine results pages.</li><li>Easy to learn: ReactJS is relatively easy to learn, even for developers with limited JavaScript experience.</li><li>Large ecosystem: There is a large ecosystem of ReactJS libraries and tools available, which can help you to build your applications more quickly and easily.</li><li>Future-proof: ReactJS is a well-maintained framework with a bright future. It is used by many large companies, and it is constantly being updated with new features.</li></ul><p>If you are looking for a powerful and versatile JavaScript framework for building web applications, then ReactJS is a great choice.</p><p>If you want to learn more about ReactJS, Kindly follow this link</p><p><a href="https://reactjs.org/">React</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=70c583e4c37d" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>