<?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" xmlns:media="http://search.yahoo.com/mrss/" version="2.0">
    <channel>
        
        <title>
            <![CDATA[ Shruti Kapoor - freeCodeCamp.org ]]>
        </title>
        <description>
            <![CDATA[ Browse thousands of programming tutorials written by experts. Learn Web Development, Data Science, DevOps, Security, and get developer career advice. ]]>
        </description>
        <link>https://www.freecodecamp.org/news/</link>
        <image>
            <url>https://cdn.freecodecamp.org/universal/favicons/favicon.png</url>
            <title>
                <![CDATA[ Shruti Kapoor - freeCodeCamp.org ]]>
            </title>
            <link>https://www.freecodecamp.org/news/</link>
        </image>
        <generator>Eleventy</generator>
        <lastBuildDate>Sun, 24 May 2026 22:23:58 +0000</lastBuildDate>
        <atom:link href="https://www.freecodecamp.org/news/author/shrutikapoor/rss.xml" rel="self" type="application/rss+xml" />
        <ttl>60</ttl>
        
            <item>
                <title>
                    <![CDATA[ How to Get Promoted from Senior to Staff Engineer – Tips from My Experience ]]>
                </title>
                <description>
                    <![CDATA[ Navigating the journey from senior engineer to staff engineer can be daunting. Promotions are often confusing, and this particular leap can feel even more ambiguous. As someone who has successfully transitioned to a Staff Engineer role, I want to sha... ]]>
                </description>
                <link>https://www.freecodecamp.org/news/how-to-get-promoted-from-senior-to-staff-engineer-tips-from-my-experience/</link>
                <guid isPermaLink="false">68880df6ebbc17df34200269</guid>
                
                    <category>
                        <![CDATA[ Career ]]>
                    </category>
                
                    <category>
                        <![CDATA[ promotion ]]>
                    </category>
                
                    <category>
                        <![CDATA[ engineering ]]>
                    </category>
                
                <dc:creator>
                    <![CDATA[ Shruti Kapoor ]]>
                </dc:creator>
                <pubDate>Mon, 28 Jul 2025 23:55:34 +0000</pubDate>
                <media:content url="https://cdn.hashnode.com/res/hashnode/image/upload/v1753746889847/3c80439e-4c98-467f-8d3c-9c7e08e56a4a.png" medium="image" />
                <content:encoded>
                    <![CDATA[ <p>Navigating the journey from senior engineer to staff engineer can be daunting. Promotions are often confusing, and this particular leap can feel even more ambiguous.</p>
<p>As someone who has successfully transitioned to a Staff Engineer role, I want to share my insights and experiences to help you on this journey.</p>
<p>In this article, I’ll address key questions you might have, like:</p>
<ul>
<li><p>What is a Staff Engineer and how does the role differ from a Senior Engineer?</p>
</li>
<li><p>What do you need to become a Staff Engineer?</p>
</li>
<li><p>How do you know you’re ready?</p>
</li>
<li><p>Who do you talk to for guidance?</p>
</li>
</ul>
<p>I’ll also share my personal story and a structured six-month plan to help you achieve your goals. Let’s dive in!</p>
<p>If you’d also like to watch this as a video, check this out:</p>
<div class="embed-wrapper">
        <iframe width="560" height="315" src="https://www.youtube.com/embed/CpiR7qznMBc" style="aspect-ratio: 16 / 9; width: 100%; height: auto;" title="YouTube video player" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen="" loading="lazy"></iframe></div>
<p> </p>
<h3 id="heading-heres-what-well-cover">Here’s what we’ll cover:</h3>
<ol>
<li><p><a class="post-section-overview" href="#heading-my-path-to-becoming-a-staff-engineer">My Path to Becoming a Staff Engineer</a></p>
</li>
<li><p><a class="post-section-overview" href="#heading-what-is-a-staff-engineer">What is a Staff Engineer?</a></p>
</li>
<li><p><a class="post-section-overview" href="#heading-story-time-building-font-selection-in-slack">Story Time: Building Font Selection in Slack</a></p>
</li>
<li><p><a class="post-section-overview" href="#heading-the-key-differences-between-staff-engineers-and-senior-engineers">The Key Differences between Staff Engineers and Senior Engineers</a></p>
<ul>
<li><a class="post-section-overview" href="#heading-staff-engineer-vs-manager-role">Staff Engineer vs Manager Role</a></li>
</ul>
</li>
<li><p><a class="post-section-overview" href="#heading-why-you-might-not-be-promoted-yet">Why You Might Not Be Promoted Yet</a></p>
</li>
<li><p><a class="post-section-overview" href="#heading-how-to-become-a-staff-engineer">How to Become a Staff Engineer</a></p>
</li>
<li><p><a class="post-section-overview" href="#heading-evaluation-criteria">Evaluation Criteria</a></p>
</li>
<li><p><a class="post-section-overview" href="#heading-how-to-build-your-staff-engineer-portfolio">How to Build Your Staff Engineer Portfolio</a></p>
</li>
<li><p><a class="post-section-overview" href="#heading-the-promotion-process">The Promotion Process</a></p>
</li>
<li><p><a class="post-section-overview" href="#heading-a-six-month-plan-to-get-promoted">A Six-Month Plan to Get Promoted</a></p>
</li>
<li><p><a class="post-section-overview" href="#heading-wrapping-up">Wrapping Up</a></p>
</li>
</ol>
<h2 id="heading-my-path-to-becoming-a-staff-engineer">My Path to Becoming a Staff Engineer</h2>
<p>Over the last decade, I’ve worked at companies like PayPal and Slack, progressing from a Junior web developer to a Staff Engineer. Here’s a quick timeline:</p>
<ul>
<li><p>Junior Web Developer at Telus Communications in 2013</p>
</li>
<li><p>Web Developer at Pix System in 2017</p>
</li>
<li><p>Software Engineer 2 at PayPal in 2018</p>
<ul>
<li>Promoted to Senior Software Engineer in 2019 and later Staff Engineer in 2021.</li>
</ul>
</li>
<li><p>Lead Member of Technical Staff at Slack in 2022</p>
<ul>
<li>Worked for three years before transitioning to full-time content creation.</li>
</ul>
</li>
</ul>
<p>One key lesson I’ve learned: <strong>It’s not just about what you do – it’s about who knows what you do.</strong></p>
<h2 id="heading-what-is-a-staff-engineer">What is a Staff Engineer?</h2>
<p>A Staff Engineer is a <strong>technical leader</strong> who drives their team’s effectiveness. You’re judged not only by the features you deliver but also by how you enable and grow your team. It’s not just about code anymore. Staff engineering is a blend of technical expertise, leadership, and mentorship.</p>
<h3 id="heading-the-four-pillars-of-staff-engineering">The Four Pillars of Staff Engineering:</h3>
<ol>
<li><p><strong>Technical excellence:</strong> Staff Engineers build scalable systems, evaluate technologies, and make critical technical decisions while managing technical debt.</p>
</li>
<li><p><strong>Organizational impact:</strong> They solve problems that extend beyond their team, acting as the communication link between various stakeholders.</p>
</li>
<li><p><strong>Mentorship and team development:</strong> Staff Engineers grow their team by helping others succeed, onboarding new members, and leveling up their colleagues.</p>
</li>
<li><p><strong>Project leadership:</strong> They ensure projects are delivered on time, breaking down complex problems into manageable pieces while leading cross-functional initiatives.</p>
</li>
</ol>
<h2 id="heading-story-time-building-font-selection-in-slack">Story Time: Building Font Selection in Slack</h2>
<p>As a Staff Engineer, I’ve had the privilege to work on some truly exciting projects. Not only have these opportunities helped me grow my technical expertise, but they’ve also taught me critical interpersonal skills – like team coordination, estimation, overcoming imposter syndrome, managing burnout, and effective delegation. These are essential qualities for any engineer looking to advance their career.</p>
<p>One standout project was the <strong>Font Selection</strong> feature in Slack. On the Appearance tab in Slack’s Preferences, users can now select a font – let’s say, Comic Sans – and instantly see the change reflected everywhere in the application.</p>
<p>This project was a classic example of a greenfield initiative: it had never been done before in Slack. That meant navigating technical debt, considering migrations to new systems, and sometimes deprecating outdated components. It also required collaboration with teams across the organization, because the blast radius of a feature like this was huge. The work impacted not just one area, but the entire user experience.</p>
<p>Being a technical leader on such a project was both challenging and rewarding. It stretched my skills and reinforced the importance of cross-functional teamwork and technical vision in delivering high-impact features.</p>
<p><img src="https://shrutikapoor.dev/images/staff-software-engineer/slack-font-selection-screenshot.jpg" alt="Font selection feature in Slack" class="image--center mx-auto" width="812" height="508" loading="lazy"></p>
<h2 id="heading-the-key-differences-between-staff-engineers-and-senior-engineers">The Key Differences between Staff Engineers and Senior Engineers</h2>
<p><strong>Senior Engineers</strong> are excellent executors who can take complex requirements and turn them into working software. They solve technical problems efficiently and mentor junior developers on their team.</p>
<p><strong>Staff Engineers</strong> are strategic thinkers who identify what problems need to be solved in the first place. They look across the entire organization to find opportunities for impact and then create projects to address them.</p>
<p>Senior Engineers are typically assigned projects by their manager or team lead and work on priorities set by their leadership. They excel at executing defined work and solving complex problems within their domain.</p>
<p>Staff Engineers, however, operate on a bigger scale beyond their team. They proactively look for improvements in the engineering organization and code architecture. Rather than waiting for direction, they chart out a plan to improve the codebase – figuring out performance optimizations, analyzing customer feedback, enhancing developer productivity, reducing technical debt.</p>
<p>When Staff Engineers identify these improvement areas, they don’t just raise tickets or file requests. They take ownership of crafting solutions by defining a project scope, writing a tech spec, outlining deliverables and creating architectural designs. This shift from reactive to proactive work represents one of the key transitions in moving from senior to staff level.</p>
<blockquote>
<p><strong>Think of it this way: Senior Engineers are given projects, Staff Engineers make projects.</strong></p>
</blockquote>
<p>Staff Engineering isn't about being a better individual contributor. It's about multiplying the effectiveness of everyone around you and growing others.</p>
<h3 id="heading-staff-engineer-vs-manager-role">Staff Engineer vs Manager Role</h3>
<p>While Staff Engineers interview new candidates, mentor engineers, provide feedback, and chart out technical direction, their role significantly differs from a Manager-level position in most companies. Although some responsibilities overlap, there are key distinctions between these two career tracks.</p>
<p><strong>Staff Engineers do not:</strong></p>
<ol>
<li><p>Participate in the hiring and firing decisions.</p>
</li>
<li><p>Have input in promotion process beyond providing feedback for the employee</p>
</li>
<li><p>Have direct reports</p>
</li>
<li><p>Hold formal management authority</p>
</li>
</ol>
<p>The fundamental distinction:</p>
<ul>
<li><p>Staff Engineer: Technical leader who influences through expertise and mentorship</p>
</li>
<li><p>Manager: Combines HR, technical, and project leadership with formal authority</p>
</li>
</ul>
<p>In most organizations, Staff Engineering and Management represent two distinct career advancement paths, allowing technical professionals to grow in seniority and impact without transitioning into people management roles.</p>
<p><img src="https://substackcdn.com/image/fetch/$s_!FOSi!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3dd518bd-6083-4101-bfa7-31bc0b80f16a_1146x1150.png" alt="Introduction to Staff Engineering - Alex Ewerlöf Notes" width="1146" height="1150" loading="lazy"></p>
<h2 id="heading-why-you-might-not-be-promoted-yet">Why You Might Not Be Promoted Yet</h2>
<p>Here are five common reasons holding people back:</p>
<h3 id="heading-waiting-to-be-told-youre-ready">Waiting to Be Told You’re Ready</h3>
<p>Many people fall into the trap of waiting for their manager to tap them on the shoulder and say, "You're ready for promotion." This passive approach can keep you stuck for years. The reality is that nobody will come to you to hand you anything. Promotion committees don't promote people based on potential – they promote based on evidence of current performance at the next level.</p>
<p><strong>Fix</strong>: Start performing like a Staff Engineer today. Take ownership of cross-team initiatives, mentor junior developers, and drive technical decisions. Share your accomplishments with the broader team.</p>
<p>When you act like a Staff Engineer consistently for 6-12 months and everyone knows how well you are performing, the promotion becomes a formality rather than a leap of faith.</p>
<p><strong>Action Item:</strong> Identify one area where you can begin operating at Staff level this month. Whether it's leading a technical design review or mentoring a junior engineer, start demonstrating the behaviors you want to be recognized for. Share status updates on a regular cadence – daily or weekly depending on the team and project, and share challenges encountered and solutions developed. This will get you not only noticed, but also help to create a balance of self-promotion and knowledge sharing.</p>
<p>Believe in yourself – don’t wait for external validation.</p>
<h3 id="heading-imposter-syndrome"><strong>Imposter Syndrome</strong></h3>
<p>That voice in your head saying "I'm not smart enough" or "I don't know enough" is imposter syndrome. Everyone feels like an imposter at some point. But successful people take action DESPITE feeling like an imposter.</p>
<p>If you let imposter syndrome dictate your actions or prevent you from taking action, you'll hold yourself back from achieving great things. The people you look up to online have also faced imposter syndrome. Most successful people encounter it weekly, if not daily. The difference is that they learn to set it aside and create a plan to move forward.</p>
<p><strong>The Fix:</strong> Reframe your mindset. Instead of thinking "I don't know X," think "I don't know X yet." Focus on your growth trajectory, not your current knowledge gaps. Remember, you were hired for your potential, not because you already knew everything.</p>
<p><strong>Action Item:</strong> Keep a "brag document" where you document your accomplishments weekly. When imposter syndrome strikes, review this evidence of your capabilities and impact. Over time, you'll notice that you overcame things that felt hard or impossible in the moment.</p>
<p>You can do hard things!</p>
<p>I made a detailed video highlighting strategies to overcome imposter syndrome. You can check it out here:</p>
<div class="embed-wrapper">
        <iframe width="560" height="315" src="https://www.youtube.com/embed/2n6Mu39Q3m4" style="aspect-ratio: 16 / 9; width: 100%; height: auto;" title="YouTube video player" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen="" loading="lazy"></iframe></div>
<p> </p>
<h3 id="heading-waiting-to-become-a-deep-technical-expert">Waiting to Become a Deep Technical Expert</h3>
<p>Many engineers think they need to know everything about every technology before they can get promoted. This "I must be perfect" thinking will hurt your career. Staff Engineers don't need to know everything. The most important skills you need to know is how to find answers and help others solve hard problems.</p>
<p><strong>The Fix:</strong> Learn a little about many things instead of learning everything about one thing. A Staff Engineer who knows some things about databases, systems, and websites will be able to perform and help more effectively than someone who only knows one thing really well. You'll learn more when you work on big projects as a Staff Engineer.</p>
<p><strong>Action Item:</strong> Pick 2-3 tech areas that you don't know much about but your company uses, or pick a new tech stack. Spend 30 minutes each week learning about each one. Focus on how they work with the systems you already know.</p>
<p>If you don’t believe in yourself, why should others?</p>
<h3 id="heading-avoiding-politics">Avoiding Politics</h3>
<p>Many engineers think that talking about their accomplishments is "playing politics" and they don't do it. This will ruin their career. Telling people about your wins isn't boastful bragging – it’s necessary. Your boss and the promotion committee can't help you if they don't know what you did.</p>
<p><strong>The Fix:</strong> Reframe self-advocacy as data sharing. You're providing factual information about your impact to help leadership make informed decisions. Create a monthly update template that includes: projects completed, problems solved, metrics improved, and people mentored. You are sharing facts, not making up stories.</p>
<p><strong>Action Item:</strong> Start a bi-weekly email to your manager highlighting your key contributions. Include specific metrics when possible: "Reduced API response time by 40%, impacting 10,000 daily users" rather than "Improved API performance."</p>
<p>If you don’t toot your own horn, who will?</p>
<h3 id="heading-struggling-with-networking">Struggling with Networking</h3>
<p>Internal networking feels awkward to many engineers, but it's crucial for Senior-level and Staff-level promotion. Staff Engineers need to influence across the organization, which requires relationships with people beyond their immediate team.</p>
<p><strong>The Fix:</strong> Approach networking as building genuine professional relationships rather than transactional interactions. Start with curiosity about others' work. Ask questions like "What are the biggest technical challenges your team is facing?" or "What would make your team more effective?"</p>
<p><strong>Action Item:</strong> Set a goal to have one coffee chat monthly with someone outside your immediate team. Focus on learning about their challenges and how your expertise might help. Share what you are working on and what goals you have in mind. These relationships often lead to collaboration opportunities that demonstrate your Staff-level impact.</p>
<h2 id="heading-how-to-become-a-staff-engineer"><strong>How to Become a Staff Engineer</strong></h2>
<p>Every company's promotion process is different, but here are some general steps that work at most places:</p>
<h3 id="heading-1-evaluate-yourself">1. Evaluate Yourself</h3>
<p>Create a requirements document using your company's engineering ladder (or a publicly available template like the <a target="_blank" href="https://www.youtube.com/watch?v=2n6Mu39Q3m4"><strong>Block Engineering Career</strong></a> <a target="_blank" href="https://assets.ctfassets.net/1wryd5vd9xez/3gb7ZSi95ipFegjuMWupGo/bcb0dd0253297bff48a4ad083b28d924/-Public-_Block_Engineering_Career_Ladder.pdf"><strong>Ladder</strong></a>). Go through each requirement honestly and mark them as either "Achieving" or "Needs Work."</p>
<p><strong>How to do it well:</strong></p>
<ul>
<li><p>Be brutally honest with yourself. It's better to underestimate than overestimate your current level</p>
</li>
<li><p>If something feels unclear, ask for examples of each requirement from your manager or other Staff Engineers</p>
</li>
<li><p>Use concrete evidence from your work and links to PRs, not just your feelings about your abilities</p>
</li>
<li><p>Update this document every 1-2 months to track your progress</p>
</li>
</ul>
<p><strong>Common mistake:</strong> Being too generous with your self-assessment. If you're not 100% confident you're "Achieving" something, mark it as "Needs Work."</p>
<h3 id="heading-2-discuss-gaps-with-your-manager">2. Discuss Gaps with Your Manager</h3>
<p>First, schedule a one-on-one meeting with your manager to review your evaluation. Work together to identify specific projects that can help you grow in areas where you need improvement. This meeting can feel painful, but it is extremely helpful in level setting. Request feedback on your assessment to see if they agree or disagree.</p>
<p><strong>After evaluation with manager:</strong></p>
<ul>
<li><p>Have 2-3 specific areas you want to focus on</p>
</li>
<li><p>Ask about upcoming projects that could help you develop these skills</p>
</li>
<li><p>Plan out a process for achieving those goals.</p>
</li>
</ul>
<p><strong>What to ask:</strong></p>
<ul>
<li><p>"What projects in the next 6 months could help me develop [specific skill]?"</p>
</li>
<li><p>"Who are the Staff Engineers I should learn from?"</p>
</li>
<li><p>"What does success look like for someone at my level trying to get promoted?"</p>
</li>
</ul>
<p><strong>Follow-up:</strong> Send a summary email after the meeting with your agreed-upon focus areas and next steps.</p>
<h3 id="heading-3-build-a-support-squad">3. Build a Support Squad</h3>
<p>Promotion committees want to hear from multiple people about your impact. Your manager's opinion alone isn't enough. So it’s a good idea to build a support squad for yourself. These are people other than your manager, such as mentors, mentees, leadership folks or inspiring colleagues, who can vouch for your skills and impact during promotion discussions. These are essentially your “sponsors”.</p>
<p><strong>Who to include:</strong></p>
<ul>
<li><p>A skip-level manager (your manager’s manager) who can speak to your organizational impact</p>
</li>
<li><p>Engineers who have worked with you on cross-team projects</p>
</li>
<li><p>Engineers you've mentored who can talk about your leadership and teaching skills</p>
</li>
<li><p>Staff Engineers from other teams who can validate your technical decisions</p>
</li>
</ul>
<p><strong>How to build these relationships:</strong></p>
<ul>
<li><p>Volunteer for cross-team projects and initiatives</p>
</li>
<li><p>Offer to help other teams with technical challenges in your area of expertise</p>
</li>
<li><p>Attend company tech talks and ask thoughtful questions</p>
</li>
<li><p>Share your knowledge through internal presentations or documentation</p>
</li>
</ul>
<p>These relationships should be genuine, not transactional. Focus on offering value first.</p>
<h3 id="heading-4-perform-like-a-staff-engineer">4. Perform Like a Staff Engineer</h3>
<p>Promotion committees promote people who are already performing at the next level, not those who might be able to perform at that level. Start acting as a Staff Engineer now. Deliver impactful projects, mentor others, and take ownership of technical decisions.</p>
<p><strong>How to get started:</strong></p>
<ul>
<li><p>Pick one area where you can start demonstrating Staff-level impact this month</p>
</li>
<li><p>Volunteer for the next cross-team project or technical initiative</p>
</li>
<li><p>Ask your manager if you can lead the technical design for an upcoming feature</p>
</li>
<li><p>Start mentoring a junior engineer and document your impact on their growth</p>
</li>
<li><p>Share knowledge through documentation, presentations, and code reviews</p>
</li>
<li><p>Identify and address technical debt that impacts multiple teams</p>
</li>
<li><p>Evaluate new technologies and make recommendations</p>
</li>
</ul>
<h2 id="heading-evaluation-criteria">Evaluation Criteria</h2>
<p>To transition to Staff Engineer, you need to demonstrate consistent excellence across multiple dimensions. It helps to understand the evaluation criteria and take on projects that showcase the following -</p>
<h3 id="heading-deep-technical-expertise">Deep Technical Expertise</h3>
<p>You’re expected to:</p>
<ul>
<li><p>Write detailed technical specs for others to follow.</p>
</li>
<li><p>Define shared standards (e.g., caching layers, API contracts).</p>
</li>
<li><p>Improve system-wide architecture across teams (e.g., microservices communication that lowers latency by 40%).</p>
</li>
</ul>
<p>Examples of projects that exhibit these skills:</p>
<ol>
<li><p>Architecting scalable, fault-tolerant systems (e.g., disaster recovery for payment processing).</p>
</li>
<li><p>Redesigning systems like user login to support 50M+ daily users with 99.99% uptime.</p>
</li>
</ol>
<h3 id="heading-problem-solving-amp-innovation">Problem Solving &amp; Innovation</h3>
<p>You’re expected to:</p>
<ul>
<li><p>Build reusable tools or frameworks widely adopted by others.</p>
</li>
<li><p>Lead new tech adoption (e.g., Kubernetes, chaos engineering).</p>
</li>
<li><p>Set engineering-wide standards through your innovations.</p>
</li>
</ul>
<p>Examples of projects that exhibit these skills:</p>
<ul>
<li><p>Fixing infinity mirroring problem in video recording software. (I did this and filed my first patent!)</p>
</li>
<li><p>Solving memory leaks or production crashes.</p>
</li>
<li><p>Creating innovative solutions that reduce cost or improve performance</p>
</li>
</ul>
<h3 id="heading-technology-leadership"><strong>Technology Leadership</strong></h3>
<p>You improve the team's quality standards and lead technical decisions, such as by-</p>
<ol>
<li><p>Making thoughtful buid-vs-buy decisions</p>
</li>
<li><p>Reducing technical debt</p>
</li>
<li><p>Establishing best practices and ensure team follows them</p>
</li>
<li><p>Leading tech migrations while ensuring 0 downtime.</p>
</li>
<li><p>Giving helpful, educational code review feedback</p>
</li>
<li><p>Setting team-wide coding, testing, and review standards</p>
</li>
<li><p>Creating templates, guides, and documentation that improve efficiency.</p>
</li>
</ol>
<h3 id="heading-mentoring-engineers"><strong>Mentoring Engineers</strong></h3>
<p>You help other engineers grow by:</p>
<ul>
<li><p>Guiding junior/mid-level engineers through complex systems.</p>
</li>
<li><p>Reviewing designs and code thoughtfully.</p>
</li>
<li><p>Teaching system design, architecture, and debugging skills.</p>
</li>
</ul>
<p>You might:</p>
<ul>
<li><p>Create learning plans (e.g., 6-month onboarding curriculum).</p>
</li>
<li><p>Host workshops (e.g., debugging production, distributed systems).</p>
</li>
<li><p>Help others think like system designers.</p>
</li>
<li><p>Help other engineers get promoted.</p>
</li>
</ul>
<h2 id="heading-how-to-build-your-staff-engineer-portfolio">How to Build Your Staff Engineer Portfolio</h2>
<p>Think of your portfolio as your promotion story. It should represent your accomplishments over the past 12–18 months, backed by clear proof. You’re not just showing what you’ve built – you’re showing how you think, how you lead, and the impact you’ve made.</p>
<h3 id="heading-what-to-include">What to Include</h3>
<p>Your portfolio should be 10-15 pages that tell a compelling story about your technical leadership. Here’s what makes a strong Staff Engineer portfolio:</p>
<ul>
<li><p><strong>Executive summary</strong>: One-page overview highlighting your most significant contributions</p>
</li>
<li><p><strong>Technical leadership projects</strong>: 3-4 major initiatives presented as detailed case studies</p>
</li>
<li><p><strong>Metrics dashboard</strong>: Quantified impact across performance, cost savings, and adoption rates</p>
</li>
<li><p><strong>Peer testimonials</strong>: External validation from engineers across different teams</p>
</li>
<li><p><strong>Growth trajectory</strong>: A 12–18 month view of how your scope and influence have grown.</p>
</li>
</ul>
<h3 id="heading-how-to-structure-each-case-study">How to Structure Each Case Study</h3>
<p>Each case study should follow a structured format that tells a complete story. First, you’ll want to discuss the problem statement: what was broken? Who was affected? Why did it matter?</p>
<p>Then cover the technical approach you took. You can discuss the high-level architecture, key decisions, and trade-offs you considered. After this, you can discuss how you implemented everything – the timeline, how you coordinated your team, and any technical challenges you faced.</p>
<p>Finally, you’ll share your results and discuss the business and technical impact with before-after metrics. It’s also a good idea to share any lessons learned and talk about what you'd do differently and how it contributed to your growth.</p>
<h2 id="heading-the-promotion-process"><strong>The Promotion Process</strong></h2>
<p>Most companies use a committee-based approach where your manager advocates for your promotion using a comprehensive packet of evidence. The committee asks one simple question: <strong>Do we know this person and do we trust their credibility?</strong></p>
<p>Your manager submits a promotion packet to the committee and you are evaluated against everyone else who is up for promotion. To help your manager put your best foot forward in front of the committee, I recommend that you build a promotion packet with your manager. This packet includes a few key components.</p>
<h3 id="heading-1-career-plan-amp-engineering-ladder-evaluation">1. Career Plan &amp; Engineering Ladder Evaluation</h3>
<p>This is the same document that you have hopefully been working on with your manager for a while. This document maps your current performance against your company's engineering ladder criteria. This isn't just a self-assessment – it's a strategic document with concrete evidence for each competency level.</p>
<p><strong>Key elements to include:</strong></p>
<ul>
<li><p>Line-by-line evaluation against ladder criteria</p>
</li>
<li><p>Specific examples and proof points for each skill area</p>
</li>
<li><p>Clear demonstration of "Achieving" performance across all relevant categories</p>
</li>
<li><p>Identification of any gaps and plans to address them</p>
</li>
</ul>
<h3 id="heading-2-portfolio-amp-proof-of-accomplishments">2. Portfolio &amp; Proof of Accomplishments</h3>
<p>Make sure your portfolio explains not just what you accomplished but the impact you made along with proofs. It should include:</p>
<ol>
<li><p>Code examples and design documents</p>
</li>
<li><p>Finished projects and improvements you made</p>
</li>
<li><p>Feedback from users and coworkers</p>
</li>
<li><p>Comments from code reviews and awards you got</p>
</li>
</ol>
<h3 id="heading-3-brag-document">3. Brag Document</h3>
<p>We’ve talked about this a bit already, but this detailed log serves as your professional highlight reel, demonstrating both quantitative metrics and qualitative growth over your review period.</p>
<p><strong>Quantitative metrics to track:</strong></p>
<ul>
<li><p>Pull requests created and reviewed</p>
</li>
<li><p>Features delivered and timeline performance</p>
</li>
<li><p>Code review discussions</p>
</li>
<li><p>Bug fix rates and system improvements</p>
</li>
<li><p>Performance optimizations achieved</p>
</li>
</ul>
<p><strong>Qualitative accomplishments to document:</strong></p>
<ul>
<li><p>Technical leadership moments</p>
</li>
<li><p>Cross-functional collaboration successes</p>
</li>
<li><p>Mentoring and knowledge sharing contributions</p>
</li>
<li><p>Innovation and creative solutions implemented</p>
</li>
</ul>
<p><strong>Growth documentation:</strong></p>
<ul>
<li><p>New technologies learned and applied</p>
</li>
<li><p>Leadership opportunities taken</p>
</li>
<li><p>Feedback incorporation and skill development</p>
</li>
</ul>
<h3 id="heading-4-testimonials">4. Testimonials</h3>
<p>Get recommendations from teammates, other departments, people you helped, and customers. Ask them to give specific examples.</p>
<p>Your packet should be organized, based on facts, and show how you've grown. Make it simple for the committee to see your value and for your manager to speak up for you.</p>
<h2 id="heading-a-six-month-plan-to-get-promoted">A Six-Month Plan to Get Promoted</h2>
<p>Here’s a structured approach to help you navigate your promotion:</p>
<h3 id="heading-month-1-evaluate-yourself">Month 1: Evaluate Yourself</h3>
<p>Review your company’s engineering ladder and assess your gaps. If they don't have one, use a publicly available career ladder.</p>
<h3 id="heading-month-2-create-a-plan">Month 2: Create a Plan</h3>
<p>Discuss your evaluation with your manager. Identify projects to address your gaps.</p>
<h3 id="heading-month-3-work-on-impactful-projects">Month 3: Work on Impactful Projects</h3>
<p>Start networking with your skip-level manager and other stakeholders.</p>
<h3 id="heading-month-4-gather-proof">Month 4: Gather Proof</h3>
<p>Document your work, seek feedback, and build evidence of your contributions.</p>
<h3 id="heading-month-5-review-progress">Month 5: Review Progress</h3>
<p>Update your career doc and review it with your manager.</p>
<h3 id="heading-month-6-keep-going">Month 6+: Keep Going</h3>
<p>The process may take longer than six months, but persistence and structure will help you get there. Don’t worry if it does take longer – that doesn’t mean you’re not qualified or won’t make it. Keep working at it.</p>
<h2 id="heading-wrapping-up">Wrapping Up</h2>
<p>Promotion isn’t always about skills – it’s also about timing and organizational factors. If you’re feeling burnt out or unsure about continuing in tech, it’s okay to pause or reconsider your path.</p>
<p>Take charge of your career. Advocate for yourself and share your accomplishments. And if you need personalized guidance, book a one-on-one session coaching session with me to create a personalized plan for you: <a target="_blank" href="https://topmate.io/shrutikapoor08">https://topmate.io/shrutikapoor08</a>.</p>
<p>If you enjoyed this article, share it with someone you know and spread the love.</p>
<h3 id="heading-connect-with-me">Connect with Me:</h3>
<ul>
<li><p>YouTube: <a target="_blank" href="https://www.youtube.com/@shrutikapoor08"><strong>https://www.youtube.com/@shrutikapoor08</strong></a></p>
</li>
<li><p>Sign up for articles like this: <a target="_blank" href="http://bit.ly/shruti-newsletter">http://bit.ly/shruti-newsletter</a></p>
</li>
<li><p>Discord: <a target="_blank" href="https://discord.com/invite/umJXpbuCXE"><strong>bit.ly/shruti-discord</strong></a></p>
</li>
<li><p>Twitter: <a target="_blank" href="https://x.com/shrutikapoor08"><strong>@shrutikapoor08</strong></a></p>
</li>
<li><p>Instagram: <a target="_blank" href="https://shrutikapoor.dev/posts/@itsshrutikapoor"><strong>https://www.instagram.com/itsshrutikapoor/</strong></a></p>
</li>
</ul>
 ]]>
                </content:encoded>
            </item>
        
            <item>
                <title>
                    <![CDATA[ React 19 Actions – How to Simplify Form Submission and Loading States ]]>
                </title>
                <description>
                    <![CDATA[ React 19 introduces Actions, which are asynchronous functions. Actions are helpful in making form submissions easier. This tutorial dives into what Actions are and how to use them. You'll learn about: The new React 19 feature, Actions The new React ... ]]>
                </description>
                <link>https://www.freecodecamp.org/news/react-19-actions-simpliy-form-submission-and-loading-states/</link>
                <guid isPermaLink="false">66b99d04489480391dfe7a4d</guid>
                
                    <category>
                        <![CDATA[ React ]]>
                    </category>
                
                <dc:creator>
                    <![CDATA[ Shruti Kapoor ]]>
                </dc:creator>
                <pubDate>Tue, 02 Jul 2024 21:29:47 +0000</pubDate>
                <media:content url="https://www.freecodecamp.org/news/content/images/2024/07/React--1-.jpg" medium="image" />
                <content:encoded>
                    <![CDATA[ <p>React 19 introduces Actions, which are asynchronous functions. Actions are helpful in making form submissions easier. This tutorial dives into what Actions are and how to use them.</p>
<p>You'll learn about:</p>
<ol>
<li>The new React 19 feature, Actions</li>
<li>The new React 19 hooks, <code>useActionState</code> and <code>useFormStatus</code></li>
<li>How to convert a React 18 form to a React 19 form</li>
</ol>
<p>I also made a <a target="_blank" href="https://www.youtube.com/watch?v=ExZUdkfu-KE&amp;t=443s">video version of this article</a> if you'd like to learn from that as well.</p>
<h2 id="heading-feature-react-actions">Feature: React Actions</h2>
<p>To understand Actions, let's first take a look at how we manage forms today. In React 18 and earlier, we submit forms using the <code>handleSubmit</code> function in a button. Here's a simple form that has one input field <code>name</code>:</p>
<pre><code class="lang-jsx"><span class="hljs-comment">// Form submission in React 18</span>
<span class="hljs-built_in">console</span>.info(<span class="hljs-string">'React 18 form'</span>);

<span class="hljs-keyword">const</span> [name, setName] = useState(<span class="hljs-string">''</span>);
<span class="hljs-keyword">const</span> [isPending, setIsPending] = useState(<span class="hljs-literal">false</span>);

<span class="hljs-keyword">const</span> handleChange = <span class="hljs-function">(<span class="hljs-params">event</span>) =&gt;</span> {
  setName(event.target.value);
};

<span class="hljs-keyword">const</span> handleSubmit = <span class="hljs-function">(<span class="hljs-params">event</span>) =&gt;</span> {
  event.preventDefault();
  setIsPending(<span class="hljs-literal">true</span>);
  <span class="hljs-built_in">setTimeout</span>(<span class="hljs-function">() =&gt;</span> {
    <span class="hljs-comment">// call API</span>
    setIsPending(<span class="hljs-literal">false</span>);
  }, <span class="hljs-number">500</span>);
};

<span class="hljs-keyword">return</span> (
  <span class="xml"><span class="hljs-tag">&lt;<span class="hljs-name">form</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">input</span> <span class="hljs-attr">type</span>=<span class="hljs-string">"text"</span> <span class="hljs-attr">name</span>=<span class="hljs-string">"name"</span> <span class="hljs-attr">onChange</span>=<span class="hljs-string">{handleChange}</span> /&gt;</span>
    {isPending ? <span class="hljs-tag">&lt;<span class="hljs-name">p</span>&gt;</span>Loading...<span class="hljs-tag">&lt;/<span class="hljs-name">p</span>&gt;</span> : <span class="hljs-tag">&lt;<span class="hljs-name">p</span>&gt;</span>Hello in React 18, {name}<span class="hljs-tag">&lt;/<span class="hljs-name">p</span>&gt;</span>}
    <span class="hljs-tag">&lt;<span class="hljs-name">button</span> <span class="hljs-attr">onClick</span>=<span class="hljs-string">{handleSubmit}</span> <span class="hljs-attr">disabled</span>=<span class="hljs-string">{isPending}</span>&gt;</span>
      Update
    <span class="hljs-tag">&lt;/<span class="hljs-name">button</span>&gt;</span>
  <span class="hljs-tag">&lt;/<span class="hljs-name">form</span>&gt;</span></span>
);
</code></pre>
<p>In this code, we are doing the following:</p>
<ol>
<li>Adding a loading state: We use a variable <code>isPending</code> to manually keep track of the loading state.</li>
<li>Form submission: The form is submitted using the <code>handleSubmit</code> event handler attached to the <code>onClick</code> event of the button.</li>
<li>Capturing the submitted value: The <code>handleChange</code> function captures the submitted value and stores it in state variables.</li>
</ol>
<h2 id="heading-what-are-react-actions">What Are React Actions?</h2>
<p>With React 19, handling forms becomes easier with Actions, inspired by frameworks such as Remix. One key feature is the enhanced use of <code>startTransition</code> to manage pending states.</p>
<p><code>startTransition</code> was introduced in React 18, allowing developers to mark certain updates as less urgent. </p>
<p>In React 19, <code>startTransition</code> can now handle async functions, making it even more powerful for managing asynchronous tasks and improving the user experience during form submissions.</p>
<pre><code class="lang-js"><span class="hljs-keyword">const</span> [isPending, startTransition] = useTransition();

<span class="hljs-keyword">const</span> handleSubmit = <span class="hljs-function">() =&gt;</span> {
  startTransition(<span class="hljs-keyword">async</span> () =&gt; {
    <span class="hljs-keyword">const</span> error = <span class="hljs-keyword">await</span> updateName(name);
    <span class="hljs-keyword">if</span> (error) {
      setError(error);
      <span class="hljs-keyword">return</span>;
    }
    redirect(<span class="hljs-string">'/path'</span>);
  });
};
</code></pre>
<p>This async function inside <code>startTransition</code> is called an Action. What makes actions cool is that they can be used directly to submit forms like so:</p>
<pre><code class="lang-html"><span class="hljs-tag">&lt;<span class="hljs-name">form</span> <span class="hljs-attr">action</span>=<span class="hljs-string">"{actionFn}"</span>&gt;</span>...<span class="hljs-tag">&lt;/<span class="hljs-name">form</span>&gt;</span>
</code></pre>
<p>This format may look familiar if you are experienced with PHP.</p>
<h2 id="heading-how-to-create-a-react-action">How to Create a React Action</h2>
<p>To create an async function, we can use a new hook introduced in React 19 called <code>useActionState</code>. We call this hook and pass in an action function and an initial state. This hook returns the updated state and a form action <code>actionFn</code>, which can be used to wire up a form.</p>
<pre><code class="lang-js"><span class="hljs-keyword">const</span> [state, actionFn] = useActionState(submitAction, { <span class="hljs-attr">name</span>: <span class="hljs-string">''</span> });
</code></pre>
<p>Now with this wired up with the form, we have the following:</p>
<pre><code class="lang-jsx">&lt;form action={actionFn}&gt;
  <span class="xml"><span class="hljs-tag">&lt;<span class="hljs-name">input</span> <span class="hljs-attr">type</span>=<span class="hljs-string">"text"</span> <span class="hljs-attr">name</span>=<span class="hljs-string">"name"</span> /&gt;</span></span>

  <span class="xml"><span class="hljs-tag">&lt;<span class="hljs-name">button</span> <span class="hljs-attr">type</span>=<span class="hljs-string">"submit"</span> <span class="hljs-attr">disabled</span>=<span class="hljs-string">"{pending}"</span>&gt;</span>
    Update
  <span class="hljs-tag">&lt;/<span class="hljs-name">button</span>&gt;</span></span>
&lt;/form&gt;
</code></pre>
<p>To add a loading state, we can use a new hook introduced in React 19 called <code>useFormStatus</code>.</p>
<pre><code class="lang-js"><span class="hljs-keyword">const</span> { pending, data, method, action } = useFormStatus();
</code></pre>
<p>This hook provides information on the status of the form. The <code>pending</code> state indicates whether the form is being submitted, and <code>data</code> is a <code>FormData</code> object containing the submitted data. We use this pending state to show a loader.</p>
<p>But there is one caveat: this hook can only be used in a child component, not in the form itself. So, we have to create child components <code>SubmitButton</code> and <code>Loader</code> to retrieve a <code>pending</code> state:</p>
<pre><code class="lang-js"><span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">Loader</span>(<span class="hljs-params"></span>) </span>{
  <span class="hljs-keyword">const</span> { pending } = useFormStatus();
  <span class="hljs-keyword">return</span> <span class="xml"><span class="hljs-tag">&lt;<span class="hljs-name">div</span>&gt;</span>{pending &amp;&amp; "Loading..."}<span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span></span>;
}

<span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">SubmitButton</span>(<span class="hljs-params"></span>) </span>{
  <span class="hljs-keyword">const</span> { pending } = useFormStatus();
  <span class="hljs-keyword">return</span> (
    <span class="xml"><span class="hljs-tag">&lt;<span class="hljs-name">button</span> <span class="hljs-attr">type</span>=<span class="hljs-string">"submit"</span> <span class="hljs-attr">disabled</span>=<span class="hljs-string">{pending}</span>&gt;</span>
      Update
    <span class="hljs-tag">&lt;/<span class="hljs-name">button</span>&gt;</span></span>
  );
}

....

return(
<span class="xml"><span class="hljs-tag">&lt;<span class="hljs-name">form</span> <span class="hljs-attr">action</span>=<span class="hljs-string">{formAction}</span>&gt;</span>
      <span class="hljs-tag">&lt;<span class="hljs-name">input</span> <span class="hljs-attr">type</span>=<span class="hljs-string">"text"</span> <span class="hljs-attr">name</span>=<span class="hljs-string">"name"</span> /&gt;</span>
      <span class="hljs-tag">&lt;<span class="hljs-name">Loader</span> /&gt;</span>
      <span class="hljs-tag">&lt;<span class="hljs-name">SubmitButton</span> /&gt;</span>
    <span class="hljs-tag">&lt;/<span class="hljs-name">form</span>&gt;</span></span>
)
</code></pre>
<p>We can also capture useful information about the data submitted to the form by retrieving it from the state returned from <code>useActionState</code>.</p>
<pre><code class="lang-js"><span class="hljs-keyword">const</span> [state, formAction] = useActionState(submitAction, { <span class="hljs-attr">name</span>: <span class="hljs-string">''</span> });
</code></pre>
<p>So here's the final form:</p>
<pre><code class="lang-jsx"><span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">Loader</span>(<span class="hljs-params"></span>) </span>{
  <span class="hljs-keyword">const</span> { pending } = useFormStatus();
  <span class="hljs-keyword">return</span> <span class="xml"><span class="hljs-tag">&lt;<span class="hljs-name">div</span>&gt;</span>{pending &amp;&amp; 'Loading...'}<span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span></span>;
}

<span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">SubmitButton</span>(<span class="hljs-params"></span>) </span>{
  <span class="hljs-keyword">const</span> { pending } = useFormStatus();
  <span class="hljs-keyword">return</span> (
    <span class="xml"><span class="hljs-tag">&lt;<span class="hljs-name">button</span> <span class="hljs-attr">type</span>=<span class="hljs-string">"submit"</span> <span class="hljs-attr">disabled</span>=<span class="hljs-string">{pending}</span>&gt;</span>
      Update
    <span class="hljs-tag">&lt;/<span class="hljs-name">button</span>&gt;</span></span>
  );
}

<span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">Name</span>(<span class="hljs-params">{ name }</span>) </span>{
  <span class="hljs-keyword">return</span> <span class="xml"><span class="hljs-tag">&lt;<span class="hljs-name">p</span>&gt;</span>Hello in 19 {name}<span class="hljs-tag">&lt;/<span class="hljs-name">p</span>&gt;</span></span>;
}

<span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">App</span>(<span class="hljs-params"></span>) </span>{
  <span class="hljs-built_in">console</span>.info(<span class="hljs-string">'React 19 form'</span>);

  <span class="hljs-keyword">const</span> [state, formAction] = useActionState(submitAction, { <span class="hljs-attr">name</span>: <span class="hljs-string">''</span> });

  <span class="hljs-keyword">return</span> (
    <span class="xml"><span class="hljs-tag">&lt;<span class="hljs-name">form</span> <span class="hljs-attr">action</span>=<span class="hljs-string">{formAction}</span>&gt;</span>
      <span class="hljs-tag">&lt;<span class="hljs-name">input</span> <span class="hljs-attr">type</span>=<span class="hljs-string">"text"</span> <span class="hljs-attr">name</span>=<span class="hljs-string">"name"</span> /&gt;</span>
      <span class="hljs-tag">&lt;<span class="hljs-name">Loader</span> /&gt;</span>
      <span class="hljs-tag">&lt;<span class="hljs-name">SubmitButton</span> /&gt;</span>
      <span class="hljs-tag">&lt;<span class="hljs-name">Name</span> <span class="hljs-attr">name</span>=<span class="hljs-string">{state?.name}</span> /&gt;</span>
    <span class="hljs-tag">&lt;/<span class="hljs-name">form</span>&gt;</span></span>
  );
}
</code></pre>
<p>Compare this with the React 18 form at the top of this post to check the difference.</p>
<h2 id="heading-conclusion">Conclusion</h2>
<p>By utilizing actions along with hooks like <code>useActionState</code> and <code>useFormStatus</code>, we can easily manage form states, capture submitted data, and provide responsive feedback to users during form submissions to show pending states. </p>
<p>I am excited for this improved experience of handling forms in React 19, and I look forward to removing unnecessary <code>handleSubmits</code>, <code>useState</code>s, and <code>pending</code> states.</p>
<p>In my next article, I will discuss another exciting new React feature: the React Compiler. This tool automatically memoizes, eliminating the need for <code>useMemo</code> and <code>useCallback</code>. Stay updated and get the article directly in your inbox by joining my newsletter.</p>
<div class="embed-wrapper"><iframe src="https://shrutikapoor.substack.com/embed" width="480" height="320" style="border:1px solid #EEE;background:white" title="Embedded content" loading="lazy"></iframe></div>

 ]]>
                </content:encoded>
            </item>
        
            <item>
                <title>
                    <![CDATA[ How to Create Animated Bubbles with HTML5 Canvas and JavaScript ]]>
                </title>
                <description>
                    <![CDATA[ Hello everyone! Welcome to this tutorial where we're going to dive into the world of creating fun bubbles in code using HTML canvas and JavaScript. The best part? We'll achieve all of this using just a touch of HTML and all JavaScript, no CSS. What w... ]]>
                </description>
                <link>https://www.freecodecamp.org/news/how-to-create-animated-bubbles-with-html5-canvas-and-javascript/</link>
                <guid isPermaLink="false">66b99cdfbe5923657131acf1</guid>
                
                    <category>
                        <![CDATA[ animation ]]>
                    </category>
                
                    <category>
                        <![CDATA[ HTML5 ]]>
                    </category>
                
                    <category>
                        <![CDATA[ JavaScript ]]>
                    </category>
                
                <dc:creator>
                    <![CDATA[ Shruti Kapoor ]]>
                </dc:creator>
                <pubDate>Tue, 05 Sep 2023 14:08:02 +0000</pubDate>
                <media:content url="https://www.freecodecamp.org/news/content/images/2023/08/shrutikapoor.dev--11-.jpg" medium="image" />
                <content:encoded>
                    <![CDATA[ <p>Hello everyone! Welcome to this tutorial where we're going to dive into the world of creating fun bubbles in code using HTML canvas and JavaScript. The best part? We'll achieve all of this using just a touch of HTML and all JavaScript, no CSS.</p>
<h2 id="heading-what-we-will-learn">What we will learn</h2>
<p>In this article, you're going to master the following concepts:</p>
<ul>
<li>How to create circles using the <code>arc</code> method of the canvas context.</li>
<li>How to utilize the <code>requestAnimationFrame</code> function for smooth circle animations.</li>
<li>How to harness the power of JavaScript classes to create multiple circles without repeating code.</li>
<li>How to add stroke styles and fill styles to your circles for a 3D bubble effect.</li>
</ul>
<p>You can follow along with me, or use <a target="_blank" href="https://codepen.io/shrutikapoor08/pen/wvQXMVO">the final codepen</a> if you want to take a look at the source code.</p>
<p>If you prefer to learn in a video format, follow along this video:</p>
<div class="embed-wrapper">
        <iframe width="560" height="315" src="https://www.youtube.com/embed/IjPgXP3gDyI" style="aspect-ratio: 16 / 9; width: 100%; height: auto;" title="YouTube video player" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen="" loading="lazy"></iframe></div>
<h2 id="heading-getting-started">Getting Started</h2>
<p>First things first, we need an HTML5 Canvas element. Canvas is a powerful element for creating shapes, images and graphics. This is what we'll use for creating the bubbles.</p>
<p>Let’s set it up:</p>
<pre><code class="lang-html"><span class="hljs-tag">&lt;<span class="hljs-name">canvas</span> <span class="hljs-attr">id</span>=<span class="hljs-string">"canvas"</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">canvas</span>&gt;</span>
</code></pre>
<p>In order to do anything meaningful with canvas, we need to have access to it’s <code>context</code>. <a target="_blank" href="https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D">Context</a> provides an interface to render objects on the canvas and draw shapes.</p>
<p>Here's how to get access to canvas and it's context.</p>
<pre><code class="lang-js"><span class="hljs-keyword">const</span> canvas = <span class="hljs-built_in">document</span>.getElementById(<span class="hljs-string">'canvas'</span>);
<span class="hljs-keyword">const</span> context = canvas.getContext(<span class="hljs-string">'2d'</span>);
</code></pre>
<p>We'll also set up our canvas to use the entire window height and width:</p>
<pre><code class="lang-js">canvas.width = <span class="hljs-built_in">window</span>.innerWidth;
canvas.height = <span class="hljs-built_in">window</span>.innerHeight;
</code></pre>
<p>Next, we'll give it canvas a nice soothing light blue background by adding some css. This is the only CSS we're going to use. You can also do this with JavaScript if you wish.</p>
<pre><code class="lang-css"><span class="hljs-selector-id">#canvas</span> {
  <span class="hljs-attribute">background</span>: <span class="hljs-number">#00b4ff</span>;
}
</code></pre>
<h2 id="heading-how-to-create-bubbles-with-canvas">How to Create Bubbles with Canvas</h2>
<p>Let’s get to the fun part. We're going to create bubbles by clicking on the canvas. To achieve this, we'll start by creating a click event handler:</p>
<pre><code class="lang-js">canvas.addEventListener(<span class="hljs-string">'click'</span>, handleDrawCircle);
</code></pre>
<p>Since we need to know where we clicked on our canvas, we are going to keep track of it in our <code>handleDrawCircle</code> function and use the event’s coordinates:</p>
<pre><code class="lang-js">
<span class="hljs-comment">//We are adding x and y here because we will need it later.</span>
<span class="hljs-keyword">let</span> x, y
<span class="hljs-keyword">const</span> handleDrawCircle = <span class="hljs-function">(<span class="hljs-params">event</span>) =&gt;</span> {
  x = event.pageX;
  y = event.pageY;

  <span class="hljs-comment">// Draw a bubble!</span>
  drawCircle(x, y);
};
</code></pre>
<h3 id="heading-how-to-draw-circles-using-the-arc-method">How to Draw Circles Using the <code>arc</code> Method</h3>
<p>To create circles, we're going to utilize the <a target="_blank" href="https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/arc"><code>arc</code> method available on canvas’s context.</a> The <code>arc</code> method accepts <code>x</code> and <code>y</code> (the center of the circle), a radius, and a start angle and end angle which for us will be <code>0</code> and <code>2* Math.PI</code> respectively because we're creating a full circle.</p>
<p>That is:</p>
<pre><code class="lang-js"><span class="hljs-keyword">const</span> drawCircle = <span class="hljs-function">(<span class="hljs-params">x, y</span>) =&gt;</span> {
  context.beginPath();
  context.arc(x, y, <span class="hljs-number">50</span>, <span class="hljs-number">0</span>, <span class="hljs-number">2</span> * <span class="hljs-built_in">Math</span>.PI);

  context.strokeStyle = <span class="hljs-string">'white'</span>;
  context.stroke();
};
</code></pre>
<p><img src="https://dev-to-uploads.s3.amazonaws.com/uploads/articles/1zrbq3gcpff40nbvzbt8.png" alt="Drawing circles" width="1118" height="912" loading="lazy">
<em>circles created using the arc method</em></p>
<h3 id="heading-how-to-move-circles-using-the-requestanimationframe-method">How to Move Circles Using the <code>requestAnimationFrame</code> Method</h3>
<p>Now that we have circles, let's make them move because...</p>
<p><img src="https://media.giphy.com/media/ptS6CV6Ty7Dt26k6wq/giphy.gif" alt="A scene from the &quot;I like to move it&quot; song from the movie -Madagascar" width="480" height="270" loading="lazy"></p>
<p>Remember that when we created a circle, we used the <code>arc</code> method which accepted <code>x</code> and <code>y</code> coordinates — the center of the circle. If we move the <code>x</code> and <code>y</code> coordinate of our circle really fast, it will give an impression that the circles are moving. Let’s try that!</p>
<pre><code class="lang-js"><span class="hljs-comment">//Define a speed by which to increment to the x and y coordinates</span>

<span class="hljs-keyword">const</span> dx = <span class="hljs-built_in">Math</span>.random() * <span class="hljs-number">3</span>;
<span class="hljs-keyword">const</span> dy = <span class="hljs-built_in">Math</span>.random() * <span class="hljs-number">7</span>;

<span class="hljs-comment">//Incremenet the center of the circle with this speed</span>
x = x + dx;
y = y - dy;
</code></pre>
<p>We can move this inside a function:</p>
<pre><code class="lang-js"><span class="hljs-keyword">let</span> x, y;

<span class="hljs-keyword">const</span> move = <span class="hljs-function">() =&gt;</span> {
  <span class="hljs-keyword">const</span> dx = <span class="hljs-built_in">Math</span>.random() * <span class="hljs-number">3</span>;
  <span class="hljs-keyword">const</span> dy = <span class="hljs-built_in">Math</span>.random() * <span class="hljs-number">7</span>;

  x = x + dx;
  y = y - dy;
};
</code></pre>
<p>To give our circle a seamless movement, we're going to create an <code>animate</code> function and use the browser's <code>requestAnimationFrame</code> method to create a moving circle:</p>
<pre><code class="lang-js"><span class="hljs-keyword">const</span> animate = <span class="hljs-function">() =&gt;</span> {
  context.clearRect(<span class="hljs-number">0</span>, <span class="hljs-number">0</span>, canvas.width, canvas.height);

  move();
    drawCircle(x,y);

  requestAnimationFrame(animate);
};

<span class="hljs-comment">//Don't forget to call animate at the bottom </span>
animate();
</code></pre>
<p><img src="https://dev-to-uploads.s3.amazonaws.com/uploads/articles/z01uy7e82sqia06svu5t.gif" alt="Circle animating" width="571" height="622" loading="lazy">
<em>moving circles created with requestAnimationFrame method</em></p>
<h3 id="heading-how-to-create-particles-using-a-particle-class">How to Create Particles Using a Particle Class</h3>
<p>Now that we have created one circle, it’s time to create multiple circles! But before we do that, let's prepare our code.</p>
<p>In order to avoid repeating our code, we are going to use classes and introduce a <code>Particle</code> class. Particles are the building blocks of our dynamic artwork and animation. Each bubble is a particle with its own position, size, movement, and color attributes. Let's define a <strong><code>Particle</code></strong> class to encapsulate these properties:</p>
<pre><code class="lang-js"><span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">Particle</span> </span>{
  <span class="hljs-keyword">constructor</span>(x = 0, y = 0) {}

  draw() {
    <span class="hljs-comment">// Drawing the particle as a colored circle</span>
    <span class="hljs-comment">// ...</span>
  }

  move() {
    <span class="hljs-comment">// Implementing particle movement</span>
    <span class="hljs-comment">// ...</span>
  }
}
</code></pre>
<p>Let’s move some of the constants we had set up to the <code>Particle</code> class:</p>
<pre><code class="lang-js"><span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">Particle</span> </span>{
  <span class="hljs-keyword">constructor</span>(x = 0, y = 0) {
    <span class="hljs-built_in">this</span>.x = x;
    <span class="hljs-built_in">this</span>.y = y;
    <span class="hljs-built_in">this</span>.radius = <span class="hljs-built_in">Math</span>.random() * <span class="hljs-number">50</span>;
    <span class="hljs-built_in">this</span>.dx = <span class="hljs-built_in">Math</span>.random() * <span class="hljs-number">3</span>;
    <span class="hljs-built_in">this</span>.dy = <span class="hljs-built_in">Math</span>.random() * <span class="hljs-number">7</span>;
  }

  draw() {
    <span class="hljs-comment">// Drawing the particle as a colored circle</span>
    <span class="hljs-comment">// ...</span>
  }

  move() {
    <span class="hljs-comment">// Implementing particle movement</span>
    <span class="hljs-comment">// ...</span>
  }
}
</code></pre>
<p>The <strong><code>draw</code></strong> method will be responsible for rendering the particle on the canvas. We have already implemented this functionality in <code>drawCircle</code>, so let’s move it in our class and update the variables to be class variables:</p>
<pre><code class="lang-js"><span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">Particle</span> </span>{
  <span class="hljs-keyword">constructor</span>(x = 0, y = 0) {
    <span class="hljs-built_in">this</span>.x = x;
    <span class="hljs-built_in">this</span>.y = y;
    <span class="hljs-built_in">this</span>.radius = <span class="hljs-built_in">Math</span>.random() * <span class="hljs-number">50</span>;
    <span class="hljs-built_in">this</span>.dx = <span class="hljs-built_in">Math</span>.random() * <span class="hljs-number">3</span>;
    <span class="hljs-built_in">this</span>.dy = <span class="hljs-built_in">Math</span>.random() * <span class="hljs-number">7</span>;
    <span class="hljs-built_in">this</span>.color = <span class="hljs-string">'white'</span>;
  }

  draw() {
    context.beginPath();
    context.arc(<span class="hljs-built_in">this</span>.x, <span class="hljs-built_in">this</span>.y, <span class="hljs-built_in">this</span>.radius, <span class="hljs-number">0</span>, <span class="hljs-number">2</span> * <span class="hljs-built_in">Math</span>.PI);
    context.strokeStyle = <span class="hljs-built_in">this</span>.color;
    context.stroke();

    context.fillStyle = <span class="hljs-built_in">this</span>.color;
    context.fill();
  }

  move() {}
}
</code></pre>
<p>Similarly, let’s move the <code>move</code> function within the class:</p>
<pre><code class="lang-js">move() {
    <span class="hljs-built_in">this</span>.x = <span class="hljs-built_in">this</span>.x + <span class="hljs-built_in">this</span>.dx;
    <span class="hljs-built_in">this</span>.y = <span class="hljs-built_in">this</span>.y - <span class="hljs-built_in">this</span>.dy;
}
</code></pre>
<p>Next, we need to make sure that we are calling the <code>Particle</code> class in our event handler:</p>
<pre><code class="lang-js"><span class="hljs-keyword">const</span> handleDrawCircle = <span class="hljs-function">(<span class="hljs-params">event</span>) =&gt;</span> {
  <span class="hljs-keyword">const</span> x = event.pageX;
  <span class="hljs-keyword">const</span> y = event.pageY;

  <span class="hljs-keyword">const</span> particle = <span class="hljs-keyword">new</span> Particle(x, y);
};

canvas.addEventListener(<span class="hljs-string">'click'</span>, handleDrawCircle);
</code></pre>
<p>Since we need to access this particle in our animate function in order to call the <code>move</code> method on it, we'll store this particle in an array called <code>particleArray</code>. This array will also be helpful when creating lots of particles. </p>
<p>Here’s the updated code to reflect this:</p>
<pre><code class="lang-js"><span class="hljs-keyword">const</span> particleArray = [];

<span class="hljs-keyword">const</span> handleDrawCircle = <span class="hljs-function">(<span class="hljs-params">event</span>) =&gt;</span> {
  <span class="hljs-keyword">const</span> x = event.pageX;
  <span class="hljs-keyword">const</span> y = event.pageY;

  <span class="hljs-keyword">const</span> particle = <span class="hljs-keyword">new</span> Particle(x, y);
  particleArray.push(particle);
};

canvas.addEventListener(<span class="hljs-string">'click'</span>, handleDrawCircle);
</code></pre>
<p>Remember to update the <code>animate</code> function too:</p>
<pre><code class="lang-javascript"><span class="hljs-keyword">const</span> animate = <span class="hljs-function">() =&gt;</span> {
    context.clearRect(<span class="hljs-number">0</span>, <span class="hljs-number">0</span>, canvas.width, canvas.height);

    particleArray.forEach(<span class="hljs-function">(<span class="hljs-params">particle</span>) =&gt;</span> {
        particle?.move();
        particle?.draw();
    });

    requestAnimationFrame(animate);
};
</code></pre>
<p>At this point, you will see these particles on your screen:</p>
<p><img src="https://dev-to-uploads.s3.amazonaws.com/uploads/articles/92rs6a5i1xn4v2gzdv8o.gif" alt="Multiple circles moving" width="624" height="464" loading="lazy"></p>
<p>Awesome! Now, to the fun part! Let's creates lots of circles and style them to make them look like bubbles.</p>
<p>To create lots of bubbles, we are going to create particles using a <code>for</code> loop and add them to the <code>particleArray</code> we had created.</p>
<pre><code class="lang-js"><span class="hljs-keyword">const</span> handleDrawCircle = <span class="hljs-function">(<span class="hljs-params">event</span>) =&gt;</span> {
  <span class="hljs-keyword">const</span> x = event.pageX;
  <span class="hljs-keyword">const</span> y = event.pageY;

  <span class="hljs-keyword">for</span> (<span class="hljs-keyword">let</span> i = <span class="hljs-number">0</span>; i &lt; <span class="hljs-number">50</span>; i++) {
    <span class="hljs-keyword">const</span> particle = <span class="hljs-keyword">new</span> Particle(x, y);
    particleArray.push(particle);
  }
};

canvas.addEventListener(<span class="hljs-string">'click'</span>, handleDrawCircle);
</code></pre>
<p>In the animate function, we'll continuously update the canvas by clearing it and redrawing the particles in their new positions. This will give an illusion of the circle moving:</p>
<pre><code class="lang-js"><span class="hljs-keyword">const</span> animate = <span class="hljs-function">() =&gt;</span> {
  context.clearRect(<span class="hljs-number">0</span>, <span class="hljs-number">0</span>, canvas.width, canvas.height);

  particleArray.forEach(<span class="hljs-function">(<span class="hljs-params">particle</span>) =&gt;</span> {
    particle?.move();
    particle?.draw();
  });

  requestAnimationFrame(animate);
};

animate();
</code></pre>
<p><img src="https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ya5u8w8qetqkcy2nbowe.gif" alt="Multiple circles animating" width="694" height="616" loading="lazy"></p>
<p>Now that we have bubbles moving, it’s time to add color to them to make them look like actual bubbles!</p>
<p>We will do this by adding a gradient fill to the bubbles. This can be done using the <code>context.createRadialGradient</code> method:</p>
<pre><code class="lang-js"><span class="hljs-keyword">const</span> gradient = context.createRadialGradient(
  <span class="hljs-built_in">this</span>.x,
  <span class="hljs-built_in">this</span>.y,
  <span class="hljs-number">1</span>,
  <span class="hljs-built_in">this</span>.x + <span class="hljs-number">0.5</span>,
  <span class="hljs-built_in">this</span>.y + <span class="hljs-number">0.5</span>,
  <span class="hljs-built_in">this</span>.radius
);

gradient.addColorStop(<span class="hljs-number">0.3</span>, <span class="hljs-string">'rgba(255, 255, 255, 0.3)'</span>);
gradient.addColorStop(<span class="hljs-number">0.95</span>, <span class="hljs-string">'#e7feff'</span>);

context.fillStyle = gradient;
</code></pre>
<p><img src="https://dev-to-uploads.s3.amazonaws.com/uploads/articles/l80yde62l9mw3ceh1f1i.gif" alt="Bubbles" width="934" height="711" loading="lazy"></p>
<p><a target="_blank" href="https://codepen.io/shrutikapoor08/pen/wvQXMVO">Here’s the final codepen</a> if you want to take a look at the source code.</p>
<h2 id="heading-wrap-up">Wrap Up</h2>
<p>Congratulations! You've just created something super fun using only HTML Canvas and JavaScript. You've learned how to use the <code>arc</code> method, how to leverage the <code>requestAnimationFrame</code> method, how to harness the power of JavaScript classes, and how to style your bubbles using gradients for the 3D bubble effect.</p>
<p>Feel free to experiment with colors, speeds, and sizes to make your animations truly unique.</p>
<p>I hope you had as much fun following this tutorial as I did creating it. Now, it's your turn to experiment. I would love to see if you tried this out and what you created. Share with me your code link and I would love to check it out.</p>
<hr>
<p>And now a #DevJoke:</p>
<p>Question - Who won the debate for the best name for loop variable?</p>
<p>Answer - i won.</p>
<hr>
<p>If you enjoyed this article, share it with someone who will benefit from it. </p>
<p>If you are interested in articles like this and front-end articles on JavaScript, React, GraphQL or Accessibility and career advice from a Staff Engineer, <a target="_blank" href="https://tinyletter.com/shrutikapoor">sign up for my newsletter</a> and get these directly in your inbox.</p>
 ]]>
                </content:encoded>
            </item>
        
            <item>
                <title>
                    <![CDATA[ How to Deliver Powerful Tech Conference Talks ]]>
                </title>
                <description>
                    <![CDATA[ Have you ever wanted to share your expertise at conferences, but something inside you is holding you back?  Perhaps it's the fear of speaking in front of a large audience, the worry of forgetting your words, or the challenge of finding the perfect to... ]]>
                </description>
                <link>https://www.freecodecamp.org/news/tips-for-speaking-at-tech-conferences/</link>
                <guid isPermaLink="false">66b99d0658397b25420b5b91</guid>
                
                    <category>
                        <![CDATA[ conference ]]>
                    </category>
                
                    <category>
                        <![CDATA[ Public Speaking ]]>
                    </category>
                
                    <category>
                        <![CDATA[ Tech Talk ]]>
                    </category>
                
                <dc:creator>
                    <![CDATA[ Shruti Kapoor ]]>
                </dc:creator>
                <pubDate>Thu, 10 Aug 2023 14:24:51 +0000</pubDate>
                <media:content url="https://www.freecodecamp.org/news/content/images/2023/08/Thumbnail1_SK.png" medium="image" />
                <content:encoded>
                    <![CDATA[ <p>Have you ever wanted to share your expertise at conferences, but something inside you is holding you back? </p>
<p>Perhaps it's the fear of speaking in front of a large audience, the worry of forgetting your words, or the challenge of finding the perfect topic to discuss. You're not alone – many aspiring speakers face these same fears.</p>
<p>But creating an engaging conference talk is a skill that you can perfect with practice. In this tutorial, I will share effective tips for crafting compelling conference talks that captivate your audience and leave a lasting impact. I'll also provide examples of inspiring presentations that have influenced me.</p>
<p>If you're looking for a comprehensive guide on speaking at conferences, check out my video where I discuss topics such as finding a conference, preparing slides, delivering engaging talks, and networking.</p>
<p><a target="_blank" href="https://www.youtube.com/embed/8ewaKFulvGc">Embedded content</a></p>
<h2 id="heading-know-your-audience">Know Your Audience</h2>
<p>It's important to understand your audience's interests and needs to tailor your content effectively.</p>
<h3 id="heading-audience-expertise-and-interests">Audience Expertise and Interests</h3>
<p>Before preparing your talk, consider the level of expertise your audience possesses. Are you addressing beginners who are eager to learn the basics, or are you speaking to seasoned professionals seeking advanced insights? Understanding this will help you customize your content accordingly.</p>
<h3 id="heading-gather-insights">Gather Insights</h3>
<p>To gain valuable insights into your audience's preferences, talk to event organizers or conduct surveys. This will give you a better understanding of their expectations and what they hope to take away from your presentation.</p>
<h3 id="heading-balance-fundamentals-and-advanced-insights">Balance Fundamentals and Advanced Insights</h3>
<p>If your audience consists of newcomers to the topic, focus on providing clear explanations of fundamentals, terminologies, and motivations. </p>
<p>On the other hand, if you have an audience with intermediate to advanced knowledge, dive into the nitty-gritty, discuss pros and cons, share opinions, and share real-life experiences.</p>
<h3 id="heading-avoid-jargon-overload">Avoid Jargon Overload</h3>
<p>Ensure that your content is accessible to everyone by avoiding excessive use of jargon. Make complex concepts understandable by using clear language and providing relevant context.</p>
<h3 id="heading-gauge-with-show-of-hands">Gauge with Show of Hands</h3>
<p>During your talk, you can engage the audience by doing a show of hands to gauge their familiarity with the topic. Based on their response, you can offer a brief 101-style introduction for those who are new to the subject, or dive directly into the main content if most of the audience is already familiar.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2023/08/image-52.png" alt="Image" width="600" height="400" loading="lazy">
<em>People responding to a question by show of hands</em></p>
<h2 id="heading-work-on-the-core-content-of-the-talk-first">Work on the Core Content of the Talk First</h2>
<p>When preparing your conference talk, focus on developing the core content and the compelling story you want to share. Design and templates can be addressed later – prioritizing your message is key.</p>
<h3 id="heading-identify-the-key-objective">Identify the Key Objective</h3>
<p>Start by answering this question: What is the one thing you want your audience to take away from your talk? This objective will be the central theme around which you build your narrative.</p>
<p>For example, if the talk is on "Angular to React migration", your key objective could be - what are the steps developers need to take to migrate their Angular app to React app. From there, your entire talk outline could frame around providing developers the background and context for providing information on migrating from Angular to React such as introduction to angular and react, need for migration, challenges and considerations, migration strategies and codebase analysis. </p>
<h3 id="heading-create-a-mind-map">Create a Mind-Map</h3>
<p>I find it helpful to create a mind-map of the topics I'll cover, centered around the main point I want my audience to remember. This approach ensures that your talk flows logically and maintains a clear focus throughout. </p>
<p>Check out this example of mind map I saw on LinkedIn for a conference talk on "32 things to help English Learners become successful readers". Mind map is a great way to ensure the talk is aligned on the key concept.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2023/08/1681680313393.jpeg" alt="Image" width="600" height="400" loading="lazy">
<em>Example of a mind map</em></p>
<h2 id="heading-tell-a-story">Tell a Story</h2>
<p>As humans, we like storytelling. Instead of just talking through your content, frame the story around why you are sharing this. </p>
<p>By telling a story that follows this format, you engage your audience on an emotional level, make your content more relatable, and leave a lasting impact. </p>
<p>Here’s a template I like for storytelling:</p>
<h3 id="heading-introduce-the-problem">Introduce the Problem</h3>
<p>Begin by describing a relatable problem or challenge you encountered. Paint a vivid picture to evoke empathy and interest from your audience.</p>
<h3 id="heading-highlight-the-impact">Highlight the Impact</h3>
<p>Illustrate the consequences and impact of the problem. Share the challenges and struggles you faced, allowing your audience to connect with your journey.</p>
<h3 id="heading-present-the-solution">Present the Solution</h3>
<p>Transition into the solution you discovered or devised. Explain how you tackled the problem and the thought process behind it. Make it clear why this solution was unique and effective.</p>
<h3 id="heading-celebrate-the-improvement">Celebrate the Improvement</h3>
<p>Describe how the solution improved your life or the lives of others involved. Share specific outcomes and successes resulting from your approach.</p>
<h3 id="heading-embrace-the-journey">Embrace the Journey</h3>
<p>Be honest about the ongoing nature of progress. Acknowledge that the journey may not be perfect, and there might be continuous efforts to maintain the positive changes.</p>
<h3 id="heading-empower-your-audience">Empower Your Audience</h3>
<p>Provide actionable insights or advice for your audience to avoid or overcome similar challenges. Encourage them to apply your learnings to their own situations.</p>
<h2 id="heading-structure-your-talk-thoughtfully">Structure Your Talk Thoughtfully</h2>
<h3 id="heading-start-with-a-captivating-hook">Start with a Captivating Hook</h3>
<p>Begin your talk with an attention-grabbing introduction. This could be an intriguing problem you encountered, a humorous joke, a compelling personal story, or a thought-provoking question. The hook sets the tone for your talk and piques the audience's curiosity.</p>
<h3 id="heading-keep-your-audience-anchored">Keep Your Audience Anchored</h3>
<p>Recognize that maintaining audience attention is crucial. To keep them engaged throughout, provide a clear roadmap at the beginning of your talk. Briefly outline what you'll be discussing, so the audience knows what to expect. </p>
<p><img src="https://www.freecodecamp.org/news/content/images/2023/08/image-109.png" alt="Image" width="600" height="400" loading="lazy">
<em>An example of outline that highlights which section is being talked about</em></p>
<p>Throughout your presentation, periodically remind them of the main points you're covering and where you are in the narrative.</p>
<h3 id="heading-deliver-smooth-transitions">Deliver Smooth Transitions</h3>
<p>Practice delivering seamless transitions between slides and sections. This ensures that your presentation flows like a cohesive narrative. </p>
<p>Familiarize yourself with your content to the extent that you know what slide comes next. Using presenter's view can be beneficial to preview the upcoming slide discreetly.</p>
<h3 id="heading-strategically-reiterate-main-points">Strategically Reiterate Main Points</h3>
<p>Identify the core messages or key takeaways you want your audience to remember. Make a conscious effort to repeat these points at various stages of your talk, reinforcing their significance.</p>
<h2 id="heading-use-visuals-in-your-talk">Use Visuals in Your Talk</h2>
<p>A picture is a thousand words. We're naturally drawn to visuals rather than lengthy text.</p>
<h3 id="heading-utilize-a-variety-of-visuals">Utilize a Variety of Visuals</h3>
<p>Incorporate images, graphics, GIFs, diagrams, illustrations, and charts to visually convey your ideas and captivate your audience. </p>
<p>Visual elements help break the monotony of text-heavy slides and enhance the overall appeal of your presentation. Explore free platforms like Unsplash and Imgur to find high-quality visuals that align with the content of your presentation. High-resolution images and graphics add a professional touch to your slides.</p>
<h3 id="heading-animate-to-explain-concepts">Animate to Explain Concepts</h3>
<p>Animations can be a great way to explain complex concepts dynamically. Consider using subtle animations to illustrate processes or step-by-step explanations. </p>
<p>As a reference, check out <strong><a target="_blank" href="https://youtu.be/cCOL7MC4Pl0?t=318">this talk</a></strong> with impressive animations explaining the JavaScript event loop.</p>
<h3 id="heading-demonstrate-with-demos">Demonstrate with Demos</h3>
<p>If your presentation includes a demo, start by showcasing the end product first. Then, take your audience through the process of building it step by step. This approach creates anticipation and helps the audience understand the context and value of your demo</p>
<h3 id="heading-ai-generated-images">AI-Generated Images</h3>
<p>For a creative touch, consider using AI-generated images created with tools like DALL-E or Midjourney. These unique visuals can add a distinctive element to your presentation. Just make sure they don't contain too many odd/unexpected features. Check out this AI generated image I created of an avocado swimming in the ocean.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2023/08/image-102.png" alt="Image" width="600" height="400" loading="lazy">
<em>An example of an AI generated image of a halved avocado floating in water</em></p>
<h2 id="heading-optimize-slide-design-for-clarity">Optimize Slide Design for Clarity</h2>
<p>Creating visually clear and appealing slides is crucial to ensure that your conference talk is effectively delivered to all members of the audience, including those seated at the back of the room. </p>
<p>Here are essential tips to optimize your slide design:</p>
<h3 id="heading-use-large-fonts">Use Large Fonts</h3>
<p>Opt for large, easy-to-read fonts that are visible from a distance. This ensures that even audience members at the back can comfortably follow your content without straining their eyes.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2023/08/image-104.png" alt="Image" width="600" height="400" loading="lazy">
<em>Large fonts from Zach Holman's talk on "How Github uses Github"</em></p>
<h3 id="heading-use-concise-text">Use Concise Text</h3>
<p>Avoid lengthy sentences on your slides. Keep the text concise and to the point. Too much text can distract the audience from your spoken words and diminish their focus on your message.</p>
<h3 id="heading-avoid-information-overload">Avoid Information Overload</h3>
<p>Refrain from cluttering your slides with excessive information. Stick to key points and use bullet points to convey your ideas succinctly. This allows the audience to grasp the main concepts without feeling overwhelmed.</p>
<h3 id="heading-format-code-clearly">Format Code Clearly</h3>
<p>When presenting code, use tools like <strong><a target="_blank" href="http://carbon.sh/">carbon.sh</a></strong> to format it in a clean and readable manner. This ensures that even complex code is understandable to your audience.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2023/08/image-55.png" alt="Image" width="600" height="400" loading="lazy">
<em>Code formatted with carbon.sh</em></p>
<h3 id="heading-ensure-visible-contrast">Ensure Visible Contrast</h3>
<p>Check the visibility and color contrast of your content against the background. Do a dry-run on the day of your talk to confirm that the slides are clearly visible on the projector or screen. Monitors can have varying color resolutions, so it's essential to be prepared.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2023/08/image-105.png" alt="Image" width="600" height="400" loading="lazy">
<em>An example of a slide with sufficient color contrast</em></p>
<h3 id="heading-avoid-distracting-design">Avoid Distracting Design</h3>
<p>While visual elements can enhance your presentation, ensure that your design template doesn't distract from the main content. Keep it clean and professional to maintain focus on your message.</p>
<h2 id="heading-avoid-over-reliance-on-presenter-notes">Avoid Over-Reliance on Presenter Notes</h2>
<p>Presenter notes can be valuable tools for staying on track during your conference talk, but it's crucial to avoid relying on them too heavily. </p>
<p>Here are key points to consider when using presenter notes effectively:</p>
<h3 id="heading-stay-natural-and-engaging">Stay Natural and Engaging</h3>
<p>Reading directly from presenter notes can make your presentation sound robotic and disengaging. Instead, aim to speak naturally and connect with your audience. </p>
<p>Familiarize yourself with the content to the point where you can convey it in a conversational manner. Treat presenter notes as aids rather than a script. They should serve as a helpful guide to remind you of key points, transitions, or specific details, but not dictate your entire presentation.</p>
<h3 id="heading-practice-makes-perfect">Practice Makes Perfect</h3>
<p>Rehearse your talk multiple times until the content becomes ingrained in your memory. By knowing your material inside out, you'll be able to deliver it smoothly without relying solely on presenter notes.</p>
<h2 id="heading-keep-your-audience-engaged">Keep Your Audience Engaged</h2>
<p>Keeping your audience engaged is essential to ensuring the success of your conference talk. By incorporating various interactive elements, you can captivate your listeners and maintain their interest. </p>
<p>Here are effective strategies to achieve this:</p>
<h3 id="heading-inject-humor-and-memes">Inject Humor and Memes</h3>
<p>Light-hearted humor and relevant memes can add a touch of fun to your presentation. Well-timed jokes and amusing visuals help create a relaxed atmosphere and make your talk more enjoyable.</p>
<p><em>Note on Jokes:</em> If a joke doesn't land as expected, simply move on without dwelling on it. Avoid explaining the joke or making the audience feel uncomfortable for not getting it.</p>
<h3 id="heading-interact-with-your-audience">Interact with Your Audience</h3>
<p>Engage your audience by asking them questions or encouraging them to participate in brief activities. Interactive elements make your talk more dynamic and involve the audience in the discussion.</p>
<h3 id="heading-offer-quick-breaks">Offer Quick Breaks</h3>
<p>If your talk contains substantial content, consider giving the audience a quick break to recharge. This break can be as simple as taking a sip of water or pausing briefly to allow the audience to take screenshots of important slides.</p>
<h3 id="heading-leverage-live-demonstrations">Leverage Live Demonstrations</h3>
<p>Live demos are excellent ways to immerse your audience in your topic. Letting the audience interact with your demos, ask questions, and explore the process hands-on keeps them engaged and interested.</p>
<h3 id="heading-share-swag-or-resources">Share Swag or Resources</h3>
<p>If appropriate, consider offering swag such as stickers, or t-shirts. This can serve as an incentive for active participation and create a positive association with your talk.</p>
<h2 id="heading-share-resources-for-ongoing-engagement">Share Resources for Ongoing Engagement</h2>
<p>Empowering your audience with valuable resources ensures that the impact of your conference talk extends beyond the event itself. Here are effective ways to share resources and foster continued engagement:</p>
<h3 id="heading-qr-codes-for-accessibility">QR Codes for Accessibility</h3>
<p>Make it easy for your audience to access your slides and additional resources by displaying QR codes at the beginning of your talk. By scanning the code, attendees can quickly access relevant materials on their devices. Check out this slide where I <a target="_blank" href="https://github.com/shrutikapoor08/talks/blob/master/Whats-new-in-React18.pdf">shared a QR code of a code demo.</a> </p>
<p><img src="https://www.freecodecamp.org/news/content/images/2023/08/image-106.png" alt="Image" width="600" height="400" loading="lazy">
<em>An example of how to share QR code in your talk for code examples.</em></p>
<h3 id="heading-tweet-links-to-slide-deck">Tweet Links to Slide Deck</h3>
<p>Increase accessibility by tweeting links to your slide deck a few minutes before your talk. This allows people to access the content during your presentation and refer back to it afterward.</p>
<h3 id="heading-provide-github-or-codesandbox-urls">Provide GitHub or CodeSandbox URLs</h3>
<p>If you demonstrate a technical project, share the URL to the corresponding GitHub repository or CodeSandbox. This enables your audience to explore the project further and gain hands-on experience with the code.</p>
<h3 id="heading-include-your-contact-information">Include Your Contact Information</h3>
<p>Display your name and contact information on every slide, ensuring that attendees can easily reach out to you after the talk. This is particularly helpful if they want to share the slides or contact you for further discussions or inquiries.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2023/08/image-108.png" alt="Image" width="600" height="400" loading="lazy">
<em>An example of including your social handle at the bottom of every slide</em></p>
<h3 id="heading-give-action-steps">Give Action Steps</h3>
<p>Leave your audience with a call-to-action or "from here, do this" tasks related to the topic. This encourages individuals interested in learning more to take action and engage further with the subject matter.</p>
<h2 id="heading-make-it-relevant-for-your-audience-not-just-you">Make it Relevant for Your Audience, Not Just You</h2>
<p>Ensuring that your conference talk resonates with your audience is essential for creating a meaningful and impactful presentation. Consider the following points to make your talk relevant and valuable for your listeners:</p>
<h3 id="heading-abstract-the-problem-and-solution">Abstract the Problem and Solution</h3>
<p>If you're sharing a talk about a problem you encountered and the solution you formed, abstract the problem to make it relatable for the audience. </p>
<p>Avoid overwhelming them with excessive technical details or specific scenarios that may not directly apply to their situations. Instead, focus on the core principles and broader implications that your audience can relate to and learn from.</p>
<h3 id="heading-avoid-over-marketing-or-over-selling">Avoid Over-Marketing or Over-Selling</h3>
<p>While it's natural to be passionate about your work or product, avoid turning your talk into a promotional pitch. </p>
<p>People attend conferences to gain knowledge and insights, not to be sold to. Provide valuable content that genuinely benefits your audience, and let the quality of your work speak for itself. Authenticity and value will naturally attract interest and followers.</p>
<p><em>Note on Self-Promotion:</em> Subtly promote your social media presence at the beginning and end of your talk, but do so in a non-intrusive manner. Mentioning your Twitter handle or other social links during the introduction and conclusion allows interested listeners to follow you for more content without feeling overwhelmed by constant promotion.</p>
<h2 id="heading-where-to-find-templates">Where to Find Templates</h2>
<p>I'm a fan of simplicity when it comes to design templates. There are various sources to find templates, such as Envato or Canva. You can also hire a designer from platforms like Fiverr or Upwork to create a custom template for you. </p>
<p>Personally, I've refined my design template in Keynote over the years, and it's the one I use most frequently. <a target="_blank" href="https://elements.envato.com/kitulah-google-slides-template-LQHBG6">This is the</a> template I started off with.</p>
<h2 id="heading-examples-of-great-talks"><strong>Examples of Great Talks</strong></h2>
<ul>
<li><strong><a target="_blank" href="https://zachholman.com/talk/how-github-uses-github-to-build-github/">Zach Holman's Talk with Huge Fonts</a></strong></li>
<li><strong><a target="_blank" href="https://www.youtube.com/watch?v=MO8hZlgK5zc&amp;list=PL37ZVnwpeshHwJPVBqEnZild7QHWhdufu&amp;ab_channel=JSConf">Jason's Talk with Great Fonts</a></strong></li>
<li><strong><a target="_blank" href="https://www.youtube.com/watch?v=cCOL7MC4Pl0&amp;ab_channel=JSConf">Andre's Funny Talk with Cool Animations</a></strong></li>
<li><strong><a target="_blank" href="https://example.com/shaundai-talk-link">Shaundai's Talk with Great Use of Visuals</a></strong></li>
</ul>
<p>Speaking at conferences is an enriching experience that allows you to share your passion and expertise with others. Following these tips will help you create powerful conference talks that leave a lasting impact on your audience. Embrace visuals, engage your listeners, and deliver valuable content that inspires and empowers others.</p>
<p>Remember, every great conference talk starts with a few seconds of courage. Take that step and share your knowledge with the world!</p>
<p>If you enjoyed this article, share it with someone who will benefit from it.</p>
<p>If you are interested in articles like this and front-end articles on JavaScript, React, GraphQL or Accessibility, <a target="_blank" href="https://tinyletter.com/shrutikapoor">sign up for my newsletter</a> and get these directly in your inbox.</p>
<h5 id="heading-follow-on-youtube-for-tutorialshttpswwwyoutubecomwatchv8ewakfulvgcampabchannelshrutikapoor"><strong><a target="_blank" href="https://www.youtube.com/watch?v=8ewaKFulvGc&amp;ab_channel=ShrutiKapoor">Follow on YouTube for tutorials</a></strong></h5>
<h5 id="heading-check-out-my-other-articleshttpslinksbstckcomredirect24aa21ac-4fe0-474b-becb-c26810fa46a0jeyj1ijoim3kwczeifqyuoy-jv4zjvq5l99bqixc-hddxjcdefpm-u20zoxmu"><strong><a target="_blank" href="https://link.sbstck.com/redirect/24aa21ac-4fe0-474b-becb-c26810fa46a0?j=eyJ1IjoiM3kwczEifQ.YUoy-jV4zjVQ5l99BQiXC-hdDxjcdeFPm-U2_0ZOXmU">Check out my other articles</a></strong></h5>
<h5 id="heading-join-on-discordhttpslinksbstckcomredirect2cc3dd27-209b-4ccf-8102-c2c425e25f4fjeyj1ijoim3kwczeifqyuoy-jv4zjvq5l99bqixc-hddxjcdefpm-u20zoxmu"><strong><a target="_blank" href="https://link.sbstck.com/redirect/2cc3dd27-209b-4ccf-8102-c2c425e25f4f?j=eyJ1IjoiM3kwczEifQ.YUoy-jV4zjVQ5l99BQiXC-hdDxjcdeFPm-U2_0ZOXmU">Join on Discord</a></strong></h5>
<p>##### </p>
 ]]>
                </content:encoded>
            </item>
        
            <item>
                <title>
                    <![CDATA[ How to Set Smart Goals You Can Actually Achieve ]]>
                </title>
                <description>
                    <![CDATA[ As we start the new year, it is a good time to reflect back on how the past 12 months went, and gear up for the next 12.  I like to spend a few hours in the beginning of the year doing a reflection of the past year, and ]]>
                </description>
                <link>https://www.freecodecamp.org/news/how-to-set-smart-goals-you-can-achieve/</link>
                <guid isPermaLink="false">66b99ce394b336889c600474</guid>
                
                    <category>
                        <![CDATA[ goal-setting ]]>
                    </category>
                
                    <category>
                        <![CDATA[ goals ]]>
                    </category>
                
                    <category>
                        <![CDATA[ motivation ]]>
                    </category>
                
                    <category>
                        <![CDATA[ self-improvement  ]]>
                    </category>
                
                <dc:creator>
                    <![CDATA[ Shruti Kapoor ]]>
                </dc:creator>
                <pubDate>Tue, 24 Jan 2023 17:45:02 +0000</pubDate>
                <media:content url="https://www.freecodecamp.org/news/content/images/2023/01/pexels-skitterphoto-15812.jpg" medium="image" />
                <content:encoded>
                    <![CDATA[ <p>As we start the new year, it is a good time to reflect back on how the past 12 months went, and gear up for the next 12. </p>
<p>I like to spend a few hours in the beginning of the year doing a reflection of the past year, and brainstorming goals for the new year. Here’s a reflection of <a target="_blank" href="https://shrutikapoor.dev/posts/2022-Recap">my 2022 year.</a></p>
<p>Setting your goals can be a daunting task. Whether you have already set your goals or still need to do so, this guide will give you the tools and resources you need to set goals that truly matter to you – and help you to achieve them. </p>
<p>It doesn’t matter whether you are starting to set your goals in January, or in the middle of the year. The best time to set your goals is now.</p>
<h2 id="heading-why-is-setting-goals-important">Why is Setting Goals Important?</h2>
<p>Goal setting is important because it provides a clear direction, a plan to follow, and a means to measure progress. It allows individuals to focus their energy and efforts on what is truly important to them, rather than getting bogged down by the many distractions in life.</p>
<p>Goals are an essential part of personal and professional development as they provide direction and purpose to our lives. Having a written goal provides a clear destination to work toward and a roadmap to follow.</p>
<h2 id="heading-framework-for-setting-goals"><strong>Framework for Setting Goals</strong></h2>
<p>In this section, we'll discuss some steps you can follow to setup actionable goals that you feel motivated to follow.</p>
<h3 id="heading-step-1-start-with-your-vision">Step 1: Start with your vision</h3>
<blockquote>
<p>There is one quality which one must possess to win, that is a definiteness of purpose, the knowledge of what one wants, and a burning desire to possess it. – Napoleon Hill</p>
</blockquote>
<p>Here are some prompts to help you set your goals:</p>
<ol>
<li><strong>Envision your legacy</strong>: What impact do you want to make and how do you want to be remembered?</li>
<li><strong>Create a 5-year vision</strong>: Imagine where you want to be in five years and what you want to have accomplished.</li>
<li><strong>Start with your dream</strong>: Think about what you would love to achieve, even if it seems unrealistic.</li>
<li><strong>Reflect on your past</strong>: Think about what you've been wanting to achieve over the last few years.</li>
<li><strong>Consider what you admire in others</strong>: What are the qualities or accomplishments that you admire in other people that you would like to adopt?</li>
<li><strong>Determine what you want to do less of:</strong> Are there any activities or habits that you want to reduce or eliminate?</li>
</ol>
<p>Write down everything that comes to your mind even if it seems crazy. Your wildest dreams may be unrealistic, but this process will help you steer yourself towards achieving them.</p>
<p>For instance, for me, my dream is to write a book that is important to developers in my community.</p>
<h3 id="heading-step-2-break-down-your-vision-into-achievable-goals">Step 2: Break down your vision into achievable goals</h3>
<blockquote>
<p>Your desire to achieve this goal must be so intense that the idea of accomplishing your goal brings you happiness and excitement. – Brian Tracy, Goals!</p>
</blockquote>
<p>Once you have written down what you want to achieve, it is now time to create goals that will help you get there. Here are some strategies for creating achievable goals.</p>
<h3 id="heading-create-goals-from-your-vision">Create goals from your vision</h3>
<p>Working backwards from your vision, think about what goals will help you get there. For example, if your dream is to run a marathon, what goals can help you achieve that? </p>
<p>An example of a goal that would help you achieve this vision would be to run 5 miles every day. For me, that goal would be to write a few words every day. Write down all your goals on a piece of a paper or a digital notepad.</p>
<h3 id="heading-prioritize-your-goals">Prioritize your goals</h3>
<p>If you have a lot of goals at this stage, it helps to pick your topmost goals. When prioritizing, I like to think about the “fire level” I have for each goal. I define “Fire level” as the feeling you get when you think about how badly do you want to achieve your goal? I use 🔥 to denote “HECK YEAH” and 💕 for “would be nice”. </p>
<p>In the book Goal!, author Brian Tracy recommends thinking about your “why” behind the goal and writing it down next to the goal. </p>
<p>Since we have finite time and it is possible you won’t be able to achieve all your goals in one year, knowing your “Why” will help you determine how much fire you have in you to achieve this goal. </p>
<p>Knowing how strongly you want your goal will also help you evaluate if this goal is worth pursuing when it is time to re-evaluate goals.</p>
<h3 id="heading-bring-goals-under-your-control">Bring goals under your control</h3>
<p>You have better chances of achieving your goal if you have control over the outcome. </p>
<p>For example, if I set a goal of becoming a best-selling author, I am setting a goal that is not under my control. I can try to write the best book I can, which is under my control, but how the audience receives it is not under my control. </p>
<p>So to bring this goal under my control, I can reframe my goal to be “write a well-researched book on topics that my audience is interested in”. Now this is under my control, and it makes it achievable for me since I can do research to ensure I am writing a well-informed and in-demand book.</p>
<h3 id="heading-identify-the-areas-that-require-improvement">Identify the areas that require improvement</h3>
<p>For each of your goals, evaluate why you have not achieved your goal yet. In his book Goals!, Tracy recommends identifying any obstacles or barriers that are preventing you from reaching your goal. </p>
<p>Be specific and thorough in considering all possible factors that may be hindering your progress. What are you missing right now to achieve your goal? Where are you good? Where do you need to improve? These are the gaps you need to work on to achieve your goal. Write these down as tasks.</p>
<h3 id="heading-define-success">Define success</h3>
<p>One of the key questions to ask yourself when measuring progress is, "How do I know I achieved this goal?" Having a clear understanding of what success looks like will help you know when you've reached your goal. </p>
<p>In the book Atomic Habits, author James Clear suggests thinking of your goals in terms of quantifiable metrics, such as numbers and percentages. This makes it easy to track progress towards your goals. </p>
<p>For example for me, I will know I am making progress towards achieving my goal if I start writing chapters and have completed a certain number of chapters in a year. So a measure of progress for me is the number of chapters I finish by the end of the year.</p>
<h3 id="heading-step-3-prepare-for-failures">Step 3: Prepare for failures</h3>
<p>As we all know, not everyone who starts a new year’s resolution sticks to it by the end of the year. </p>
<p>How long do you think it takes most people to drop their new year’s resolutions? 23% of people quit by the end of the first week, 64% after the first month (according to a study with Australian and UK citizens), and 81% before the end of the second year. </p>
<p>Why do you think that happens? It’s because people lose motivation when things get tough.</p>
<p><img src="https://dev-to-uploads.s3.amazonaws.com/uploads/articles/wdfqeo2a4sdw5cn5nrd8.png" alt="Image description" width="750" height="232" loading="lazy"></p>
<p>When we haven’t prepared ourselves for the adverse situations, it becomes hard to stay on track and be motivated to overcome hardships when progressing towards our goal. Instead, when we prepare for failures, we've prepared ourselves ahead of time to tackle the situation.</p>
<p>So to ensure success of your goal, it is important to prepare yourself by thinking about the issues or challenges that might occur. Some questions that can help your prepare yourself are:</p>
<ol>
<li>What will stop you from starting this goal?</li>
<li>What are some things that can go wrong when you are making progress?</li>
<li>What can you do when you encounter failure?</li>
<li>How can you prevent yourself from burning out?</li>
<li>How can you get back on track to keep your momentum going?</li>
</ol>
<p>Write these down next to your goals, so that when you see you are not making progress, you can use these to get back in the momentum.</p>
<p>For example, it will be my imposter syndrome and the habit of procrastination that will stop me from even starting. When I do start, I may feel bored, unmotivated or too tired at the end of the day to write anything. I may run out of ideas while writing or feel burnt out. </p>
<p>But if I prepare myself for these things in advance, I can get a better handle on things when they go south.</p>
<h3 id="heading-step-4-make-it-a-habit">Step 4: Make it a habit</h3>
<p>Once you know your goals, it's time to put them into action. Do something everyday that brings you closer to achieving them, even if it is for a few minutes. </p>
<p>To make it easier to be consistent towards your goals, it helps to establish a system that helps you achieve these habits everyday. In Atomic Habits, author James Clear discusses the importance of setting a habit system. Here are some tips from Atomic Habits that can help you establish your habit system:</p>
<h3 id="heading-find-your-clutter">Find your “clutter”</h3>
<p>Clutter is any time that is not directly progressing you towards your goal, adding to the joy of your life, or helping you relax. </p>
<p>Take an inventory of the time you are spending every day on each clutter activity. By removing your clutter, you can bring intention into your schedule and clear up time to put your goals on your calendar in the form of daily habits.</p>
<h3 id="heading-block-time-in-your-calendar-for-a-habit">Block time in your calendar for a habit</h3>
<p>It becomes a lot easier to achieve your goal, when the habit that will help you achieve that goal is scheduled in your calendar. </p>
<p>It is a lot easier to forget about a goal if it is not accounted for in your day-to-day life. Use your calendar or however you schedule your time to appoint time to achieve goals.</p>
<h3 id="heading-remove-friction">Remove friction</h3>
<p>Instead of relying on motivation, create a system that makes it easy to follow through on your good habits and hard to slip back into bad habits. </p>
<p>Think about how you can help your future self be in the right mindset to achieve the goal. Remove all distractions. </p>
<p>For example, if you are going to workout, make it easy for your future self to get to the gym by keeping your workout clothes next to your bed so you can put them on first thing in the morning, and load up your pump-up playlist on your phone so you can play as you go.</p>
<h3 id="heading-figure-out-baby-steps">Figure out baby steps</h3>
<p>Often, a goal feels overwhelming to achieve because it feels like a giant elephant we need to eat. But, how do you eat an elephant? One bite at a time. </p>
<p>Similarly, in order to build lasting habits, small, incremental changes are incredibly important. Think about what is the smallest thing you can do to make a baby step towards your goal today. </p>
<p>If you are thinking of getting in shape and are struggling to go to gym, put on your favorite workout clothes and go for a walk. Bring out your yoga mat and do an easy yoga practice. </p>
<p>The practice of finishing a small task <a target="_blank" href="https://blog.trello.com/the-psychology-of-checklists-why-setting-small-goals-motivates-us-to-accomplish-bigger-things">towards your goal can release dopamine</a>, which makes us feel motivated, joyful and successful. Our mind wants to achieve that feeling again, and so getting into the habit of achieving smaller tasks towards our goals becomes easier.</p>
<p>For me, this baby step is getting a few words on the page. I will be a lot closer to finishing my book if I put in 200 words every day. This will help me make incremental progress towards my goal by the end of the year.</p>
<h3 id="heading-be-consistent">Be consistent</h3>
<p>Consistency is key to building lasting habits. By sticking to your habits even when you don't feel like it, you'll be able to make it a part of your identity and make it stick.</p>
<h3 id="heading-step-5-find-people-who-support-you-your-hype-squad">Step 5: Find people who support you – your hype squad.</h3>
<p>Having a group of people whom you can reach out to when you are feeling low, unmotivated, doubtful, or lost is really important and often overlooked. </p>
<p>We undervalue how much we are affected by our surroundings, family and co-workers. Think about some people who affect you day-to-day – your friends, family, co-workers, social circle, and folks who you don’t interact with day-to-day but aspire to be like. </p>
<p>I like to think of this group of folks as my hype squad. These are the folks I reach out to when I am in doubt, need advice, want to feel motivated, want them to hype me up, or am just generally looking to get good vibes when I share my accomplishments. </p>
<p>Here are some roles that you should look to fill:</p>
<ol>
<li>Who is someone who can help you reach your goals? Perhaps this is someone who has already achieved this goal themselves. This person can be your mentor.</li>
<li>Who is someone who can be your cheerleader when you feel down? This person can help lift up your spirits when you are feeling doubtful of your skills.</li>
<li>Who can be your accountability buddy? This person can help you stay motivated and on track by checking in with you regularly and helping you stay accountable.</li>
<li>Who should you surround yourself with so you can stay inspired and motivated? These can be experts in the industry, or someone who is excelling in this field. This person will inspire you, motivate you, and keep you focussed on your goal.</li>
<li>Who in your household can help you achieve your goal? We often overlook the importance of family and housemates. Think of how your family can support you in achieving your goal.</li>
</ol>
<p>For example, for my book, my hype squad could include people who have written a book before, and can therefore offer me advice.</p>
<p>Staying accountable and tracking your goals becomes easier when you are part of a supportive and motivated community. For this reason, I created <a target="_blank" href="https://discord.com/invite/umJXpbuCXE">this Discord community</a>. We help each other stay on track by keeping each other accountable, checking in regularly, and hype each other up. I strongly suggest you become a member of this community.</p>
<h3 id="heading-step-6-measure-progress-and-re-evaluate-goals">Step 6: Measure progress and re-evaluate goals.</h3>
<p>Forming habits is a continuous process that requires constant reflection and adjustments in order to improve. Tracking progress, staying motivated, and making necessary changes will aid in this process.</p>
<h3 id="heading-reflect-and-adjust">Reflect and adjust</h3>
<p>Measuring progress towards your goals is an important step in achieving them. Reflect on your progress regularly and be honest with yourself. </p>
<p>If you are not making enough progress, try to understand the reasons behind it. Is it that the “Why” of your goal is not strong enough and you are not motivated to achieve this goal? Is it possible that your schedule is too busy and you don’t have time for this goal?</p>
<h3 id="heading-reward-yourself">Reward yourself</h3>
<p>To make the journey toward achieving your goal more exciting, reward yourself for reaching milestones. This can help keep you motivated and give you a sense of accomplishment. </p>
<p>Celebrating your progress by setting up rewards for yourself can be a great way to stay motivated throughout the process.</p>
<h3 id="heading-have-a-check-in-day">Have a check-in day</h3>
<p>In order to make sure your goals are working for you, setup a check-in day. During this time, you can reflect on your progress, evaluate if the goal still makes sense for you, check if your priorities are the same, and see if there are any obstacles that are preventing you from achieving the goal. </p>
<p>This could mean changing some things around your goal, stopping or pivoting if you're not making progress, or even breaking your long-term goals into smaller, more manageable chunks. </p>
<p>This is also a good time to check in with your hype-squad. This check-in day could be quarterly or monthly.</p>
<h2 id="heading-my-personal-goal-setting-tools">My Personal Goal-Setting Tools</h2>
<p>Here are my personal tools that I use to set goals:</p>
<p>Bullet Journal Goals spread – I mentioned writing down your goals on a piece of paper. I use my bullet journal to write my goals for the year. This is the spread from my 2023 bullet journal</p>
<p><img src="https://dev-to-uploads.s3.amazonaws.com/uploads/articles/khrnladlnxnag9t8k6kh.jpg" alt="Goals bullet journal spread" width="4032" height="3024" loading="lazy"></p>
<p>Notion template – I use the framework I described in this blog to break down my goal into smaller tasks, habits, my “why”, the fire level, potential failures and my hype squad. I put this in a digital format that I can keep on me at all times. <a target="_blank" href="https://www.notion.so/Goal-Setting-Template-56a6f9bd3a0b472982683f5beccc4ab6">This is the notion template I use.</a> This is inspired by <a target="_blank" href="https://www.youtube.com/watch?v=FJwp5RBLQcs&amp;ab_channel=AliAbdaal">Ali Abdaal.</a></p>
<p>Discord –This is <a target="_blank" href="https://discord.com/invite/umJXpbuCXE">my accountability community</a> to help you stay on top of your goals. This is a goals cohort, and we check-in with each other monthly. </p>
<p>I am excited to invite the community to join my Discord channel, where we will come together and support each other as we work towards our goals. Together, we will be a powerful force of accountability and motivation, pushing each other to be our best selves. </p>
<p>Whether you're working on personal development, career goals, or just looking for a supportive community, this Discord channel is the perfect place to connect with others who are on a similar journey. By joining forces, we will be able to achieve more than we ever thought possible.</p>
<p>Let's make our dreams a reality!</p>
<p>This is OUR YEAR.</p>
<h3 id="heading-thank-you-for-reading">Thank you for reading!</h3>
<p>If you enjoyed this article, share it with someone you know and spread the knowledge.</p>
<ul>
<li>For more frequent tips, <a target="_blank" href="http://twitter.com/shrutikapoor08">stay in touch on Twitter</a></li>
<li><a target="_blank" href="https://bit.ly/shrutinewsletter">Get articles like this directly in your inbox</a></li>
</ul>
 ]]>
                </content:encoded>
            </item>
        
            <item>
                <title>
                    <![CDATA[ Accessibility Best Practices – What to Remember When Building Accessible Web Apps ]]>
                </title>
                <description>
                    <![CDATA[ Anyone should be able to use your websites and apps - both people with disabilities and those without. This will make your website accessible. Think about the last site you built, or your favorite site. Are you confident that anyone can use your site... ]]>
                </description>
                <link>https://www.freecodecamp.org/news/accessibility-best-practices-to-make-web-apps-accessible/</link>
                <guid isPermaLink="false">66b99cc84ed1a5964b77008a</guid>
                
                    <category>
                        <![CDATA[ a11y ]]>
                    </category>
                
                    <category>
                        <![CDATA[ Accessibility ]]>
                    </category>
                
                    <category>
                        <![CDATA[ best practices ]]>
                    </category>
                
                    <category>
                        <![CDATA[ Web Applications ]]>
                    </category>
                
                <dc:creator>
                    <![CDATA[ Shruti Kapoor ]]>
                </dc:creator>
                <pubDate>Fri, 16 Dec 2022 21:01:26 +0000</pubDate>
                <media:content url="https://www.freecodecamp.org/news/content/images/2022/12/ben-kolde-bs2Ba7t69mM-unsplash-1.jpg" medium="image" />
                <content:encoded>
                    <![CDATA[ <p>Anyone should be able to use your websites and apps - both people with disabilities and those without. This will make your website accessible.</p>
<p>Think about the last site you built, or your favorite site. Are you confident that anyone can use your site and perform the critical actions it requires? Have you considered folks with motor disabilities, visual disabilities, cognitive disabilities, and auditory disabilities?</p>
<p>Accessibility is often left as an after-thought. When it is time to ship a feature, we do an accessibility test and find out that our site wasn't accessible and do a hacky fix. </p>
<p>Making a site accessible is a huge undertaking. But if we keep accessibility in mind from the get-go, it makes it much easier to build an accessible web app. </p>
<p>In this post, I will go over 5 things you can keep in mind WHILE building your app so you don't have to do a hacky slap together at the end.</p>
<h2 id="heading-5-things-to-remember-for-good-accessibility">5 Things to Remember for Good Accessibility</h2>
<ol>
<li>Semantinc HTML</li>
<li>Tabindex</li>
<li>Aria attributes</li>
<li>Role</li>
<li>Keyboard navigation and screen readers</li>
</ol>
<p>In short, S.T.A.R.K.</p>
<p>If you need help remembering this, think of Tony Stark. </p>
<p><img src="https://cdn.vox-cdn.com/uploads/chorus_image/image/55400215/ktokatitmir0.0.jpg" alt="TonyStark" width="3000" height="1779" loading="lazy"></p>
<p>Let's go through each of these to understand how to use them in your web apps.</p>
<h3 id="heading-what-is-semantic-html">What is Semantic HTML?</h3>
<p>Using semantic HTML is important for accessibility. This is because assistive technologies such as screen readers are able to interpret what's on the page by parsing the HTML of the page. They enable users to take actions based on the elements. </p>
<p>For example, if a screen reader encounters a <code>button</code>, it signals to the user that they should click on it. </p>
<p>Let's consider some use-cases of what can happen when you don't use semantic HTML:</p>
<h4 id="heading-creating-buttons-by-using-div-instead-of-button">Creating buttons by using <code>div</code> instead of <code>button</code>:</h4>
<p><code>div</code>s are container elements, so when a screen reader encounters a div, it automatically thinks it is a presentational element. </p>
<p>When a screen reader user encounters a <code>div</code> that has content or children within it, the screen reader announces <code>role="group"</code> and the user will completely miss that the <code>div</code> is interactive. So make sure you use the proper semantic element for its purpose. You get accessibility for free.</p>
<h4 id="heading-using-css-to-fake-headings-instead-of-using-h1-6-tags">Using CSS to fake headings instead of using <code>h1-6</code> tags:</h4>
<p>Heading tags such as <code>&lt;h1&gt;</code> and <code>&lt;h2&gt;</code> let an assitive technology know that this is important text, and the screen reader will announce "Heading". </p>
<p>When you use CSS to make a heading instead of using correct semantics, the significance of the text is lost to a screen reader.</p>
<p>So just make sure to use semantic HTML whenever possible.</p>
<h3 id="heading-what-is-tabindex">What is Tabindex?</h3>
<p>Adding a <code>tabindex</code> makes interactive elements keyboard-navigable. When you add <code>tabindex</code> to an element, a user is able to navigate to it using only their keyboard and/or assitive technologies.</p>
<ol>
<li>You use a tabindex of <code>0</code> to set focus to an element in the default tabbing order,</li>
<li>You use a tabindex of <code>-1</code> to programmatically focus an element using JavaScript.</li>
<li>Do not assign a value of &gt; 1 to tabindex.</li>
</ol>
<p>A word of caution though - you should only add <code>tabindex</code> to interactive elements. It is not a good practie to add <code>tabindex</code> to elements such as <code>div</code>. </p>
<p>Instead of adding tabindex in that case, use a semantic element, such as a <code>button</code> since semantic elements already are tabbable and do not need an additional <code>tabindex</code> value.</p>
<h3 id="heading-what-are-aria-attributes">What are ARIA attributes?</h3>
<p>Aria attributes such as <code>aria-checked</code>, <code>aria-label</code> give additional information to assistive technologies.</p>
<p>Aria attributes are a set of HTML attributes that you use to provide additional information about the purpose and state of elements on a web page. These attributes are especially beneficial to assistive technologies to provide more context and better navigation for users.</p>
<p>Some common aria-attributes include:</p>
<ol>
<li><code>aria-label</code>: used to provide a label or name for an element.</li>
<li><code>aria-hidden</code>: used to indicate that an element should be hidden from assistive technologies. This can be useful for elements that are used for layout purposes but are not relevant to the content of the page.</li>
<li><code>aria-describedby</code>: used to associate an element with a description, which helps to provide context of an element.</li>
<li><code>aria-liv</code>e: used to indicate that an element's content may change dynamically, and that assistive technologies should pay attention to changes in the element's content.</li>
</ol>
<p>You can use these attributes in combination with each other and with standard HTML attributes to create more accessible and user-friendly web content.</p>
<h3 id="heading-what-is-the-aria-role-attribute">What is the <code>aria-role</code> attribute?</h3>
<p>You use the <code>aria-role</code> attribute to define the purpose of an HTML element and provide its semantic meaning. </p>
<p>For example, if you are building a grid component with the help of CSS and divs, you can use <code>role="grid"</code> to let assistive technologies know about the semantics of the component.</p>
<p>Some common <code>aria-role</code>s include:</p>
<ol>
<li><code>button</code>: used to indicate that an element should be treated as a button.</li>
<li><code>alert</code>: used to indicate that an element is an alertbox.</li>
<li><code>presentation</code>: used to indicate that an element is only presentational.</li>
</ol>
<p>It is important to exercise caution with <code>aria-role</code>. Remember to not overdo it.</p>
<h3 id="heading-how-to-handle-keyboard-navigation-and-screen-readers">How to handle keyboard navigation and screen readers</h3>
<p>Many users with motor disabilities rely on their keyboard and assitive technologies to navigate the web. So it's critical that every component be navigable using a keyboard and screen reader. </p>
<p>You can test keyboard accessibility by navigating a site using only your keyboard. Here are some common keys:</p>
<ol>
<li><code>tab</code> key to navigate to different sections of the site.</li>
<li><code>spacebar</code> to select elements, such as a checkbox.</li>
<li><code>enter</code> to press buttons.</li>
</ol>
<p>While testing keyboard navigation, make sure you think about the following:</p>
<ol>
<li>Focus remains visible: Ensure that you can clearly see which element is being focused on the page. Focus should always remain visible.</li>
<li>Tab order: When tabbing through sections, the order of tabbing should follow the natural flow and logical structure of the website. It should not jump back and forth between sections.</li>
<li>Keyboard traps: Ensure that when navigating with the keyboard, the focus doesn't get trapped on an element. For example, this could happen when a modal is opened, or the focus is navigated to a widget, such as calendar or emoji picker. Ensure that when you select an element in the widget, you are able to navigate back to the site.</li>
</ol>
<h2 id="heading-wrapping-up">Wrapping Up</h2>
<p>Overall, testing for accessibility during development is an important part of the process that can help to create more usable and accessible software for all users. Testing for accessibility early helps to provide a great user experience for everyone.</p>
<p>In the next article, I will talk about the various accessibility tools and how to debug an accessibility issue. You can <a target="_blank" href="http://tinyletter.com/shrutikapoor">sign up to get it in your inbox here.</a></p>
<p>Until then, enjoy your holidays!</p>
<p>Feliz Navidad.</p>
 ]]>
                </content:encoded>
            </item>
        
            <item>
                <title>
                    <![CDATA[ How to Create a Habit System and Stay Motivated as a Developer ]]>
                </title>
                <description>
                    <![CDATA[ Do you ever find it challenging to work on your project, side hustle, or even your hobby?  Have you ever had those moments where nothing feels exciting? You lay in bed thinking – is it me, or is my work that boring?  I have those days too. Some ]]>
                </description>
                <link>https://www.freecodecamp.org/news/create-a-habit-system-and-stay-motivated-as-a-developer/</link>
                <guid isPermaLink="false">66b99ccf94b336889c60046f</guid>
                
                    <category>
                        <![CDATA[ Habit Building ]]>
                    </category>
                
                    <category>
                        <![CDATA[ motivation ]]>
                    </category>
                
                    <category>
                        <![CDATA[ self-improvement  ]]>
                    </category>
                
                <dc:creator>
                    <![CDATA[ Shruti Kapoor ]]>
                </dc:creator>
                <pubDate>Thu, 28 Apr 2022 00:43:46 +0000</pubDate>
                <media:content url="https://www.freecodecamp.org/news/content/images/2022/04/pexels-philip-ackermann-878151.jpg" medium="image" />
                <content:encoded>
                    <![CDATA[ <p>Do you ever find it challenging to work on your project, side hustle, or even your hobby? </p>
<p>Have you ever had those moments where nothing feels exciting? You lay in bed thinking – is it me, or is my work that boring? </p>
<p>I have those days too. Some weeks I am charged up and determined to take over the world. Other weeks, I feel low, bored, and stuck, and I feel like I don't have the motivation to write even one line of code.</p>
<p>This article will discuss what to do when you are not motivated and how to manage procrastination.</p>
<h2 id="heading-what-to-do-when-you-dont-have-motivation-to-work-on-anything">What to do when you don't have motivation to work on anything</h2>
<p>We must remember that motivation comes in many shapes and forms. Some days, motivation looks like creating art, whereas other days, it inspires you to create a blog post. </p>
<p>Some days motivation looks like going on a 7-mile hike, whereas other days, it is about taking care of yourself and working your butt off.</p>
<p>Acknowledge and appreciate each type of motivation and its form. Let it encompass you, take you on a ride, and bring you new experiences, joy, and fulfillment. Let yourself feel motivated – no matter what form it takes because motivation in one form bleeds into another.</p>
<p>Some days when I feel low, I pull out my paintbrushes, put on a Bob Ross painting tutorial, play my favorite show in the background, make myself a cup of tea, light a candle, and start painting. </p>
<p>It feels good to use this time to de-stress. I don't care too much about the quality – I care about how I feel in the moment. I feel relaxed, inspired, motivated, and like I am taking care of myself and feeling creative while I am doing it. </p>
<p>Even though I may not feel motivated to write code, I feel motivated to paint – and that's okay!</p>
<p>I then take that feeling to the next day, either to let my creativity work on my art or to help me create something else.</p>
<p>An important thing to remember is that motivation is fleeting. A burst of inspiration usually lasts 1 - 3 weeks. By only relying on motivation to fulfill your dreams and goals, you are not creating a strategy for being consistent. </p>
<p>What you need is discipline. <a target="_blank" href="https://www.freecodecamp.org/news/how-to-be-more-consistent-when-learning-to-code/">You need a system of habits</a>. A habit system keeps you going day after day and becomes part of your daily routine, even when motivation has left you.</p>
<h2 id="heading-what-is-a-habit-system-and-how-do-you-create-it">What is a habit system, and how do you create it?</h2>
<p>A habit system is a carefully thought-out daily routine of habits that take you closer to your goal. </p>
<p>It is a system of what you need to do, how long you need to do it, what ambiance you want to create before you do the things you need to do, and how you will put yourself in the right mental frame of mind. </p>
<p>For example, as a developer, think about what goals you have set for yourself? They may look like this:</p>
<ol>
<li>This week: create a feature for a project you are working on.</li>
<li>This month: learn TypeScript</li>
<li>This quarter: release project</li>
<li>This year: be proficient in React and TypeScript, speak at a conference, and create one blog every month.</li>
</ol>
<p>Now, think about how you will break down these goals into tasks, and by what deadline are you hoping to get it done. Work backward from that deadline, and see what tasks you can achieve in the short term to achieve that goal. </p>
<p>Here is an example of one of the above goals:</p>
<p><strong>Goal</strong>: create a feature for a project you are working on</p>
<p><strong>Deadline</strong>: 1 week from today.</p>
<p><strong>Steps</strong>:</p>
<ol>
<li>Research what I need – dependencies, stakeholders, assets.</li>
<li>What are the steps for creating this feature?</li>
<li>What are some open questions?</li>
<li>Who can help me?</li>
</ol>
<p><strong>Timeline</strong>:</p>
<p>Day 1: Research<br>Days 2 - 3: Development work + testing<br>Day 4: End to end testing + fixing any bugs.<br>Day 5: Deploy to staging env and get ready for demo.</p>
<p>The next step is to "make" the time to do these steps. You carve out in your calendar to make it happen. </p>
<p>Look at your calendar, and block out "focus time". This is the time when you will get these tasks done. </p>
<p>Next, create a system of "setting your mental frame". This is how you get yourself in the mood for getting work done.</p>
<h2 id="heading-my-habit-system">My Habit System</h2>
<p>I've developed my own habit system that I use to keep myself on track. I'll explain each part so you can adapt it to your own needs.</p>
<h3 id="heading-how-to-find-ideas">How to find ideas</h3>
<p>Often, I don't feel inspired to do anything because nothing is on my plate to do. I may have a lot of items in the backlog that I could work on, but I haven't given much thought to any of those ideas. And because I haven't "brought them on my plate," they don't feel as exciting. </p>
<p>So I go through my backlog or idealist and see if anything inspires me to overcome that. If not, I will browse blog articles on dev.to, freeCodeCamp, or Medium to see if any trending articles inspire creativity. </p>
<p>If not, I will find exciting conversations on Twitter. If that doesn't work, I will open Udemy or YouTube and find something to learn. </p>
<p>If none of that works, it is a signal that I need to chill out and take time to myself. I give myself a "creative" break – go on a walk, listen to a podcast. When something does inspire creativity during this break, I will write it down.</p>
<h3 id="heading-how-to-set-a-timeline">How to set a timeline</h3>
<p>Once I have a few ideas in mind, I will pick the one that excites me the most. I will put a soft deadline for me – often two weeks. Then I will work backward from the deadline and mark time in my calendar to work on that topic. </p>
<p>I usually set 1-hour slots in my calendar if my calendar is busy and longer if I have more time. Some weeks, I may only be able to carve out 2 hours, okay. </p>
<p>Once it is on my calendar, I will force myself to sit down and get myself ready for focused work hours.</p>
<h3 id="heading-how-to-set-a-mood">How to set a mood</h3>
<p>Setting a mood is crucial because having a good ambiance is vital for me and creates a stimulating environment. My stimulants are sound, smell, and sight.</p>
<p><strong>Sound</strong>: I put on a lofi or focus playlist. <a target="_blank" href="https://www.youtube.com/watch?utm_campaign=JSByte&amp;utm_medium=email&amp;utm_source=Revue%20newsletter&amp;v=csCp0Wd2-40.">This</a> is the one I commonly watch.</p>
<p><strong>Smell</strong>: I have candles and diffusers set up in my office to create a "focus vibe". Sometimes, when I need a kick, I will also use roll-on essential oils.</p>
<p><strong>Sight</strong>: I feel most motivated when someone else is working with me or when I am outside in nature. This is why my work desk faces a window where I can see trees, wind blowing, leaves rustling, and birds chirping. </p>
<p>In the youtube video I linked, the guy is also working, which makes me feel inspired to work. It's like having a working buddy. </p>
<p>I created <a target="_blank" href="http://twitch.tv/shrutikapoor?utm_campaign=JSByte&amp;utm_medium=blog&amp;utm_source=devto">a Twitch stream</a> and <a target="_blank" href="https://discord.gg/rgqyH75Saf?utm_campaign=JSByte&amp;utm_medium=blog&amp;utm_source=devto">discord server</a> for this reason. When sitting in my home office alone is not enough to motivate me, and I need external motivation, I go to a cafe. Lately, I have also been going to a neighborhood park to write, which has been very helpful in creating articles.</p>
<h3 id="heading-how-to-cut-out-distractions">How to cut out distractions</h3>
<p>This is very important to me because I have the attention span of a goldfish. If given a chance, I will merrily browse away on Twitter, keep clicking notifications, or keep scrolling on Instagram. </p>
<p>So during my focus time, I put my phone on silent, quit my email applications, and turn slack to Do not disturb mode. I tell myself that for the next 45 minutes, I will not look at my phone, answer emails, look at Twitter or open Slack. </p>
<p>If I need to stop getting distracted, I will log out of these applications. Out of sight, out of mind. 😄</p>
<h3 id="heading-how-to-get-things-going">How to get things going</h3>
<p>At this point, I have got my idea picked out, my vibe setup, my drink in my hand, my music playing, and the only thing I need to do is start typing. </p>
<p>I begin my Pomodoro timer. I work in 45-minute sessions with 15-minute breaks. I use the video I linked above as my Pomodoro timer. My goal is that I should work through the whole video by the end of the day. </p>
<p>Once the bell in the video hits "ding," I am ready. I start typing whatever comes into my head. I don't care much about polishing the content or code in the first go. This is a first go anyway. I will come back and revise the code or content repeatedly. </p>
<p>The idea here is to get it going and get the juices flowing. It's all about getting your mind to dump all the ideas out on the page.</p>
<h3 id="heading-dont-forget-to-take-a-break">Don't forget to take a break</h3>
<p>Once the timer is done, it's time to take a break. I force myself to get up, take a walk, go outside, make a new cup of tea, do an errand – anything as long as it is not scrolling away mindlessly on Twitter or Instagram. </p>
<p>This is the time for me to give myself a break. Sometimes towards the end of the break, around the 10-minute mark, I will check Slack, emails, or any urgent notifications on my phone. Sometimes, nobody needs me ☹️ so I get back to work for another 45-minute cycle.</p>
<h3 id="heading-wrap-it-up">Wrap it up</h3>
<p>I realized during these sessions that to have continuity and be motivated in the next session, I need to know what I have accomplished, where I left off, and what I have to do next. </p>
<p>For this, I will make notes at the end of the sessions, usually a revision of the above outline – what I did, what open questions I have, what I need to do in the next session, action items, and people I need to reach out to for help.</p>
<p>And so, the cycle repeats.</p>
<h2 id="heading-wrapping-up">Wrapping Up</h2>
<p>I hope this article helped you get inspired to create a habit system for yourself to keep you on track. </p>
<p>If you would like to work together on Twitch or Discord, <a target="_blank" href="http://twitter.com/shrutikapoor08?utm_campaign=JSByte&amp;utm_medium=blog&amp;utm_source=Devto">DM me on Twitter</a> telling me what is your preferred work schedule:</p>
<ol>
<li>9 AM - 11 AM PST Weekdays</li>
<li>9 PM - 11 PM PST Weekdays</li>
</ol>
<p>In the next article, I will talk about what to do when motivation does not strike, no ideas come to mind, and you need to give yourself a jolt. Stay tuned. <a target="_blank" href="http://bit.ly/shrutinewsletter?utm_campaign=JSByte&amp;utm_medium=blog&amp;utm_source=Devto">You can also receive notifications about the next article directly in your inbox.</a></p>
 ]]>
                </content:encoded>
            </item>
        
            <item>
                <title>
                    <![CDATA[ React 18 New Features – Concurrent Rendering, Automatic Batching, and More ]]>
                </title>
                <description>
                    <![CDATA[ React 18 was released in March 2022. This release focuses on performance improvements and updating the rendering engine.  React 18 sets the foundation for concurrent rendering APIs that future React features will be built on top of.  In this tutorial... ]]>
                </description>
                <link>https://www.freecodecamp.org/news/react-18-new-features/</link>
                <guid isPermaLink="false">66b99d004ed1a5964b77008f</guid>
                
                    <category>
                        <![CDATA[ features ]]>
                    </category>
                
                    <category>
                        <![CDATA[ React ]]>
                    </category>
                
                    <category>
                        <![CDATA[ update  ]]>
                    </category>
                
                <dc:creator>
                    <![CDATA[ Shruti Kapoor ]]>
                </dc:creator>
                <pubDate>Thu, 14 Apr 2022 21:58:00 +0000</pubDate>
                <media:content url="https://www.freecodecamp.org/news/content/images/2022/04/featured.jpg" medium="image" />
                <content:encoded>
                    <![CDATA[ <p>React 18 was released in March 2022. This release focuses on performance improvements and updating the rendering engine. </p>
<p>React 18 sets the foundation for concurrent rendering APIs that future React features will be built on top of. </p>
<p>In this tutorial, I will give a quick guide of the features released in React 18, and explain a few major concepts such as concurrent rendering, automatic batching and transitions.</p>
<h3 id="heading-react-18-feature-quick-guide">React 18 Feature Quick Guide</h3>
<table>
<thead>
<tr>
<th>Category</th>
<th>Feature</th>
</tr>
</thead>
<tbody>
<tr>
<td>Concept</td>
<td>Concurrent React</td>
</tr>
<tr>
<td>Features</td>
<td>Automatic Batching,  Transitions, Suspense on the server</td>
</tr>
<tr>
<td>APIs</td>
<td>createRoot, hydrateRoot, renderToPipeableStream, renderToReadableStream</td>
</tr>
<tr>
<td>Hooks</td>
<td>useId, useTransition, useDeferredValue, useSyncExternalStore, useInsertionEffect</td>
</tr>
<tr>
<td>Updates</td>
<td>Strict mode</td>
</tr>
<tr>
<td>Deprecated/discouraged</td>
<td>ReactDOM.render, renderToString</td>
</tr>
</tbody>
</table>

<p>Now let's look at each of these updates in more detail. But first, if you haven't already, let's learn how to update React.</p>
<h2 id="heading-how-to-upgrade-to-react-18">How to upgrade to React 18</h2>
<p>Install React 18 and React DOM from npm or yarn, like this:</p>
<p><code>npm install react react-dom</code></p>
<p>Then, you'll want to use <code>createRoot</code> instead of <code>render</code>.</p>
<p>In your index.js, update <code>ReactDOM.render</code> to <code>ReactDOM.createRoot</code> to create a root, and render your app using root.</p>
<p>Here's what it would look like in React 17:</p>
<pre><code class="lang-jsx"><span class="hljs-keyword">import</span> ReactDOM <span class="hljs-keyword">from</span> <span class="hljs-string">'react-dom'</span>;
<span class="hljs-keyword">import</span> App <span class="hljs-keyword">from</span> <span class="hljs-string">'App'</span>;

<span class="hljs-keyword">const</span> container = <span class="hljs-built_in">document</span>.getElementById(<span class="hljs-string">'app'</span>);

ReactDOM.render(<span class="xml"><span class="hljs-tag">&lt;<span class="hljs-name">App</span> /&gt;</span></span>, container);
</code></pre>
<p>And here's what it looks like in React 18:</p>
<pre><code class="lang-jsx"><span class="hljs-keyword">import</span> ReactDOM <span class="hljs-keyword">from</span> <span class="hljs-string">'react-dom'</span>;
<span class="hljs-keyword">import</span> App <span class="hljs-keyword">from</span> <span class="hljs-string">'App'</span>;

<span class="hljs-keyword">const</span> container = <span class="hljs-built_in">document</span>.getElementById(<span class="hljs-string">'app'</span>);

<span class="hljs-comment">// create a root</span>
<span class="hljs-keyword">const</span> root = ReactDOM.createRoot(container);

<span class="hljs-comment">//render app to root</span>
root.render(<span class="xml"><span class="hljs-tag">&lt;<span class="hljs-name">App</span> /&gt;</span></span>);
</code></pre>
<h2 id="heading-concurrency-in-react-18">Concurrency in React 18</h2>
<p>To understand concurrency, let’s consider <a target="_blank" href="https://github.com/reactwg/react-18/discussions/46">this example</a> by Dan Abramov from React 18 Working group discussions.</p>
<p>Let’s say that we need to call two people – Alice and Bob. In a non-concurrent setting, we can only have one call at a time. We would first call Alice, end the call, and then call Bob. </p>
<p>This is fine when calls are short, but if call with Alice has a long waiting period (such as on-hold), this can be a time sink.</p>
<p><img src="https://dev-to-uploads.s3.amazonaws.com/uploads/articles/io6s64j30dt3na6yxzp4.png" alt="Non-concurrent call" width="1808" height="418" loading="lazy">
<em>Image showing that in a typical non-concurrent phone conversation, you have to wait for a call to be over before starting a new call.</em></p>
<p>In a concurrent setting, we could call Alice and, once we were put on hold, we could then call Bob. </p>
<p>This doesn’t mean that we are talking to two people at the same time. It just means that we can have two or more concurrent calls at the same time and decide which call is more important.</p>
<p><img src="https://dev-to-uploads.s3.amazonaws.com/uploads/articles/v4zgvausl6go1ur769cd.png" alt="Concurrent call" width="1580" height="590" loading="lazy">
<em>Image showing phone conversation between Alice and Bob can be concurrent, by placing a call on hold and answering a more urgent call with Bob first.</em></p>
<p>Similarly, in React 18 with concurrent rendering, React can interrupt, pause, resume, or abandon a render. This allows React to respond to the user interaction quickly even if it is in the middle of a heavy rendering task. </p>
<p>Before React 18, rendering was a single, uninterrupted, synchronous transaction and once rendering started, it couldn’t be interrupted.</p>
<p>Concurrency is a foundational update to React’s rendering mechanism. Concurrency allows React to interrupt rendering. </p>
<p>React 18 introduces the foundation of concurrent rendering and new features such as suspense, streaming server rendering, and transitions are powered by concurrent rendering.</p>
<h2 id="heading-new-react-18-features">New React 18 Features</h2>
<h3 id="heading-automatic-batching">Automatic Batching</h3>
<p>React 18 features automatic batching. To understand batching, let’s consider the example of grocery shopping from the <a target="_blank" href="https://github.com/reactwg/react-18/discussions/46#discussioncomment-846694">same React Working Group discussion</a>. </p>
<p>Let’s say that you are making pasta for dinner. If you were to optimize your grocery trip, you would create a list of all the ingredients that you need to buy, make a trip to the grocery store, and get all your ingredients in one trip. </p>
<p>This is batching. Without batching, you would start cooking, find out you need an ingredient, go to the grocery store and buy the ingredient, come back and continue cooking, only to find out you need another ingredient, go to the grocery store...and drive yourself crazy.</p>
<p>In React, batching helps to reduce the number of re-renders that happen when a state changes, when you call <code>setState</code>. Previously, React batched state updates in event handlers, for example:</p>
<pre><code class="lang-jsx"><span class="hljs-keyword">const</span> handleClick = <span class="hljs-function">() =&gt;</span> {
setCounter();
setActive();
setValue();
}

<span class="hljs-comment">//re-rendered once at the end.</span>
</code></pre>
<p>However, state updates that happened outside of event handlers were not batched. For example, if you had a promise or were making a network call, the state updates would not be batched. Like this:</p>
<pre><code class="lang-jsx">fetch(<span class="hljs-string">'/network'</span>).then( <span class="hljs-function">() =&gt;</span> {
setCounter(); <span class="hljs-comment">//re-rendered 1 times</span>
setActive();  <span class="hljs-comment">//re-rendered 2 times</span>
setValue();   <span class="hljs-comment">//re-rendered 3 times</span>
});

<span class="hljs-comment">//Total 3 re-renders</span>
</code></pre>
<p>As you can tell, this is not performant. React 18 introduces automatic batching which allows all state updates – even within promises, setTimeouts, and event callbacks – to be batched. This significantly reduces the work that React has to do in the background. React will wait for a micro-task to finish before re-rendering.</p>
<p>Automatic batching is available out of the box in React, but if you want to opt-out you can use <code>flushSync</code>.</p>
<h3 id="heading-transitions">Transitions</h3>
<p>Transitions can be used to mark UI updates that do not need urgent resources for updating. </p>
<p>For example, when typing in a typeahead field, there are two things happening: a blinking cursor that shows visual feedback of your content being typed, and a search functionality in the background that searches for the data that is typed.</p>
<p>Showing a visual feedback to the user is important and therefore urgent. Searching is not so urgent, and so can be marked as non-urgent. </p>
<p>These non-urgent updates are called transitions. By marking non-urgent UI updates as "transitions", React will know which updates to prioritize. This makes it easier to optimize rendering and get rid of stale rendering.</p>
<p>You can mark updates as non-urgent by using <code>startTransition</code>. Here is an example of what a typeahead component would like when marked with transitions:</p>
<pre><code class="lang-jsx"><span class="hljs-keyword">import</span> { startTransition } <span class="hljs-keyword">from</span> <span class="hljs-string">'react'</span>;

<span class="hljs-comment">// Urgent: Show what was typed</span>
setInputValue(input);

<span class="hljs-comment">// Mark any non-urgent state updates inside as transitions</span>
startTransition(<span class="hljs-function">() =&gt;</span> {
  <span class="hljs-comment">// Transition: Show the results</span>
  setSearchQuery(input);
});
</code></pre>
<h4 id="heading-how-are-transitions-different-from-debouncing-or-settimeout">How are transitions different from debouncing or setTimeout?</h4>
<ol>
<li>startTransition executes immediately, unlike setTimeout.</li>
<li>setTimeout has a guaranteed delay, whereas startTransition's delay depends on the speed of the device, and other urgent renders.</li>
<li>startTransition updates can be interrupted unlike setTimeout and won't freeze the page.</li>
<li>React can track the pending state for you when marked with startTransition.</li>
</ol>
<h3 id="heading-suspense-on-the-server">Suspense on the server</h3>
<p>React 18 introduces:</p>
<ol>
<li>Code splitting on the server with suspense</li>
<li>Streaming rendering on the server</li>
</ol>
<h4 id="heading-client-rendering-vs-server-rendering">Client rendering vs server rendering</h4>
<p>In a client-rendered app, you load the HTML of your page from the server along with all the JavaScript that is needed to run the page, and make it interactive. </p>
<p>If, however, your JavaScript bundle is huge, or you have a slow connection, this process can take a long time and the user will be waiting for the page to become interactive, or to see meaningful content.</p>
<p><img src="https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ccfllg117u8ycgnl5mv7.png" alt="Illustration of client rendering flow. Source: React Conf 2021 Streaming Server Rendering with Suspense by Shaundai Person https://www.youtube.com/watch?v=pj5N-Khihgc" width="1944" height="956" loading="lazy">
<em>In a client rendering flow, a user has to wait a long time before the page becomes interactive. <a target="_blank" href="https://www.youtube.com/watch?v=pj5N-Khihgc">Source</a>: React Conf 2021 <strong>Streaming Server Rendering with Suspense</strong> by Shaundai Person</em></p>
<p>For optimizing the user experience and avoiding the user having to sit on a blank screen, we can use server rendering. </p>
<p>Server rendering is a technique where you render the HTML output of your React components on the server and send HTML from the server. This lets the user view some UI while JS bundles are loading and before the app becomes interactive. </p>
<p>For a detailed overview of client vs server rendering, <a target="_blank" href="https://www.youtube.com/watch?v=pj5N-Khihgc">check out Shaundai Person’s React Conf 2021 talk</a>.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2022/04/4.jpeg" alt="Image" width="600" height="400" loading="lazy">
<em>In a server rendering flow, we can display meaningful data to the user much faster by sending HTML from the server. <a target="_blank" href="https://www.youtube.com/watch?v=pj5N-Khihgc">Source</a>: React Conf 2021 <strong>Streaming Server Rendering with Suspense</strong> by Shaundai Person</em></p>
<p>Server rendering further enhances the user experience of loading the page and reducing time to interactive.</p>
<p>Now what if most of your app is fast except for one part? Maybe this part loads data slowly, or maybe it needs to download a lot of JS before it gets interactive.</p>
<p>Before React 18, this part was often the bottleneck of the app, and would increase the time it took to render the component. </p>
<p>One slow component can slow down the entire page. This is because server rendering was all or nothing – you couldn’t tell React to defer loading of a slow component and couldn’t tell React to send HTML for other components.</p>
<p>React 18 adds support for Suspense on server. With the help of suspense, you can wrap a slow part of your app within the Suspense component, telling React to delay the loading of the slow component. This can also be used to specify a loading state that can be shown while it's loading.</p>
<p>In React 18, one slow component doesn’t have to slow the render of your entire app. With Suspense, you can tell React to send HTML for other components first along with the HTML for the placeholder, like a loading spinner. Then when the slow component is ready and has fetched its data, the server renderer will pop in its HTML in the same stream.</p>
<p><img src="https://dev-to-uploads.s3.amazonaws.com/uploads/articles/taxrh7y9ylx0l68u2btx.png" alt="You can add suspense to a slow server rendered component in React 18" width="1930" height="986" loading="lazy">
<em>Image showing that suspense on the server can allow a slow component to show a loading state while others are fully rendered.</em></p>
<p>This way the user can see the skeleton of the page as early as possible and see it gradually reveal more content as more pieces of HTML Arrive. </p>
<p>All of this happens before any JS or React loads on the page, which significantly improves the user experience and user-perceived latency.</p>
<h3 id="heading-strict-mode">Strict mode</h3>
<p>Strict mode in React 18 will simulate mounting, unmounting, and re-mounting the component with a previous state. This sets the ground for reusable state in the future where React can immediately mount a previous screen by remounting trees using the same component state before unmounting. </p>
<p>Strict mode will ensure components are resilient to effects being mounted and unmounted multiple times.</p>
<h2 id="heading-conclusion">Conclusion</h2>
<p>In a summary, React 18 sets the foundation for future releases and focusses on improving the user experience. </p>
<p>Upgrading to React 18 should be straightforward and your existing code should not break after the update. The upgrade process should not take more than an afternoon. </p>
<p>Give it a go and let me know what you think!</p>
<p>Sources:</p>
<ol>
<li><a target="_blank" href="https://github.com/reactjs/rfcs/blob/react-18/text/0000-react-18.md">React RFC</a></li>
<li><a target="_blank" href="https://dev.to/shrutikapoor08/what-s-new-in-react-18-1713">My previous React 18 post</a></li>
<li><a target="_blank" href="https://reactjs.org/blog/2022/03/29/react-v18.html">React V18 blog</a></li>
<li><a target="_blank" href="https://www.youtube.com/watch?v=ytudH8je5ko">React Conf 2021 - React for App developers</a></li>
<li><a target="_blank" href="https://www.youtube.com/watch?v=pj5N-Khihgc">React Conf 2021 - Streaming Server Rendering with Suspense</a></li>
</ol>
<p>If you enjoyed this article, give it a ❤️ so others can find it too.</p>
<ul>
<li>For more frequent tips, <a target="_blank" href="http://twitter.com/shrutikapoor08">stay in touch on Twitter</a></li>
<li><a target="_blank" href="http://tinyletter.com/shrutikapoor">Want articles like this directly in your inbox?</a></li>
</ul>
 ]]>
                </content:encoded>
            </item>
        
            <item>
                <title>
                    <![CDATA[ Data Validation – How to Check User Input on HTML Forms with Example JavaScript Code ]]>
                </title>
                <description>
                    <![CDATA[ Forms are ubiquitous in web applications. Some apps use forms to collect data to sign up users and provide an email address. Others use them to fulfill online transactions to facilitate a shopping experience.  You might use some web forms to apply fo... ]]>
                </description>
                <link>https://www.freecodecamp.org/news/form-validation-with-html5-and-javascript/</link>
                <guid isPermaLink="false">66b99cd23cd81de09c96b2cf</guid>
                
                    <category>
                        <![CDATA[ Form validations ]]>
                    </category>
                
                    <category>
                        <![CDATA[ HTML5 ]]>
                    </category>
                
                    <category>
                        <![CDATA[ JavaScript ]]>
                    </category>
                
                <dc:creator>
                    <![CDATA[ Shruti Kapoor ]]>
                </dc:creator>
                <pubDate>Mon, 18 Jan 2021 17:56:53 +0000</pubDate>
                <media:content url="https://cdn-media-2.freecodecamp.org/w1280/6003768298be260817e4aadc.jpg" medium="image" />
                <content:encoded>
                    <![CDATA[ <p>Forms are ubiquitous in web applications. Some apps use forms to collect data to sign up users and provide an email address. Others use them to fulfill online transactions to facilitate a shopping experience. </p>
<p>You might use some web forms to apply for a new car loan, whereas you'll use others to order pizza for dinner. So it's important that the data collected from those forms is cleaned, formatted correctly, and devoid of any malicious code. This process is called form validation.</p>
<p>We need form validation anytime we are accepting user input. We must ensure that the data entered is in the correct format, lies within a valid range of data (such as for date fields), and does not contain malicious code that could lead to SQL injections. Malformed or missing data can also cause the API to throw errors.</p>
<h2 id="heading-what-are-the-different-types-of-form-validations">What are the different types of form validations?</h2>
<p>Form validation can happen on the client side and the server side.</p>
<p>Client side validation occurs using HTML5 attributes and client side JavaScript. </p>
<p>You may have noticed that in some forms, as soon as you enter an invalid email address, the form gives an error "Please enter a valid email". This immediate type of validation is usually done via client side JavaScript.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2021/04/form-validation-cc.gif" alt="Validation error for incorrect credit card number" width="600" height="400" loading="lazy"></p>
<p>In other cases, you may have noticed that when you fill out a form and enter details such as a credit card, it may show a loading screen and then show an error "This credit card is invalid". </p>
<p>Here, the form made a call to its server side code, and returned a validation error after performing additional credit card checks. This validation case where a server-side call is made is called server side validation.</p>
<h2 id="heading-what-data-should-be-validated">What data should be validated?</h2>
<p>Form validation is needed anytime you accept data from a user. This may include:</p>
<ol>
<li>Validating the format of fields such as email address, phone number, zip code, name, password.</li>
<li>Validating mandatory fields</li>
<li>Checking the type of data such as string vs number for fields such as social security number.</li>
<li>Ensuring that the value entered is a valid value such as country, date, and so on.</li>
</ol>
<h2 id="heading-how-to-set-up-client-side-validation">How to set up client side validation</h2>
<p>On the client side, validation can be done in two ways:</p>
<ol>
<li>Using HTML5 functionality</li>
<li>Using JavaScript</li>
</ol>
<h3 id="heading-how-to-set-up-validation-with-html5-functionality">How to set up validation with HTML5 functionality</h3>
<p>HTML5 provides a bunch of attributes to help validate data. Here are some common validation cases:</p>
<ul>
<li>Making fields required using <code>required</code></li>
<li>Constraining the length of data:<ul>
<li><code>minlength</code>, <code>maxlength</code>: for text data</li>
<li><code>min</code> and <code>max</code> for max value of num type</li>
</ul>
</li>
<li>Restricting the type of data using <code>type</code>:<ul>
<li><code>&lt;input type="email" name="multiple&gt;</code></li>
</ul>
</li>
<li>Specifying data patterns using <code>pattern</code>:<ul>
<li>specifies a regex pattern that the entered form data needs to match</li>
</ul>
</li>
</ul>
<p>When the input value matches the above HTML5 validation, it gets assigned a psuedo-class <code>:valid</code>, and <code>:invalid</code> if it doesn't.</p>
<p>Let's try an example:</p>
<pre><code class="lang-HTML"><span class="hljs-tag">&lt;<span class="hljs-name">form</span>&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-name">label</span> <span class="hljs-attr">for</span>=<span class="hljs-string">"firstname"</span>&gt;</span> First Name: <span class="hljs-tag">&lt;/<span class="hljs-name">label</span>&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-name">input</span> <span class="hljs-attr">type</span>=<span class="hljs-string">"text"</span> <span class="hljs-attr">name</span>=<span class="hljs-string">"firstname"</span> <span class="hljs-attr">id</span>=<span class="hljs-string">"firstname"</span> <span class="hljs-attr">required</span> <span class="hljs-attr">maxlength</span>=<span class="hljs-string">"45"</span>&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-name">label</span> <span class="hljs-attr">for</span>=<span class="hljs-string">"lastname"</span>&gt;</span> Last Name: <span class="hljs-tag">&lt;/<span class="hljs-name">label</span>&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-name">input</span> <span class="hljs-attr">type</span>=<span class="hljs-string">"text"</span> <span class="hljs-attr">name</span>=<span class="hljs-string">"lastname"</span> <span class="hljs-attr">id</span>=<span class="hljs-string">"lastname"</span> <span class="hljs-attr">required</span> <span class="hljs-attr">maxlength</span>=<span class="hljs-string">"45"</span>&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-name">button</span>&gt;</span>Submit<span class="hljs-tag">&lt;/<span class="hljs-name">button</span>&gt;</span>
<span class="hljs-tag">&lt;/<span class="hljs-name">form</span>&gt;</span>
</code></pre>
<p><img src="https://www.freecodecamp.org/news/content/images/2021/04/form-validation-required.png" alt="Client side form validation for required fields using HTML5 attributes" width="600" height="400" loading="lazy"></p>
<p><a target="_blank" href="https://jsfiddle.net/58xc2qyj/">Link to JSFiddle</a></p>
<p>Here we have two required fields - First Name and Last Name. Try this example in JSFidle. If you skip either of these fields and press submit, you'll get a message, "Please fill out this field". This is validation using in-built HTML5.</p>
<h3 id="heading-how-to-set-up-validation-using-javascript">How to set up validation using JavaScript</h3>
<p>When implementing form validation, there are a few things to consider:</p>
<ol>
<li>What is defined as "valid" data? This helps you answer questions about the format, length, required fields, and type of data.</li>
<li>What happens when invalid data is entered? This will help you define the user experience of the validation - whether to show an error message inline or at the top of the form, how detailed should the error message be, should the form be sumitted anyways, should there be analytics to track invalid format of data? And so on.</li>
</ol>
<p>You can perform JavaScript validation in two ways:</p>
<ol>
<li>Inline validation using JavaScript</li>
<li>HTML5 Constraint validation API</li>
</ol>
<h4 id="heading-inline-validation-using-javascript">Inline validation using JavaScript</h4>
<pre><code class="lang-html"><span class="hljs-tag">&lt;<span class="hljs-name">form</span> <span class="hljs-attr">id</span>=<span class="hljs-string">"form"</span>&gt;</span>
  <span class="hljs-tag">&lt;<span class="hljs-name">label</span> <span class="hljs-attr">for</span>=<span class="hljs-string">"firstname"</span>&gt;</span> First Name* <span class="hljs-tag">&lt;/<span class="hljs-name">label</span>&gt;</span>
  <span class="hljs-tag">&lt;<span class="hljs-name">input</span> <span class="hljs-attr">type</span>=<span class="hljs-string">"text"</span> <span class="hljs-attr">name</span>=<span class="hljs-string">"firstname"</span> <span class="hljs-attr">id</span>=<span class="hljs-string">"firstname"</span> /&gt;</span>
  <span class="hljs-tag">&lt;<span class="hljs-name">button</span> <span class="hljs-attr">id</span>=<span class="hljs-string">"submit"</span>&gt;</span>Submit<span class="hljs-tag">&lt;/<span class="hljs-name">button</span>&gt;</span>

  <span class="hljs-tag">&lt;<span class="hljs-name">span</span> <span class="hljs-attr">role</span>=<span class="hljs-string">"alert"</span> <span class="hljs-attr">id</span>=<span class="hljs-string">"nameError"</span> <span class="hljs-attr">aria-hidden</span>=<span class="hljs-string">"true"</span>&gt;</span>
    Please enter First Name
  <span class="hljs-tag">&lt;/<span class="hljs-name">span</span>&gt;</span>
<span class="hljs-tag">&lt;/<span class="hljs-name">form</span>&gt;</span>
</code></pre>
<pre><code class="lang-javascript"><span class="hljs-keyword">const</span> submit = <span class="hljs-built_in">document</span>.getElementById(<span class="hljs-string">"submit"</span>);

submit.addEventListener(<span class="hljs-string">"click"</span>, validate);

<span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">validate</span>(<span class="hljs-params">e</span>) </span>{
  e.preventDefault();

  <span class="hljs-keyword">const</span> firstNameField = <span class="hljs-built_in">document</span>.getElementById(<span class="hljs-string">"firstname"</span>);
  <span class="hljs-keyword">let</span> valid = <span class="hljs-literal">true</span>;

  <span class="hljs-keyword">if</span> (!firstNameField.value) {
    <span class="hljs-keyword">const</span> nameError = <span class="hljs-built_in">document</span>.getElementById(<span class="hljs-string">"nameError"</span>);
    nameError.classList.add(<span class="hljs-string">"visible"</span>);
    firstNameField.classList.add(<span class="hljs-string">"invalid"</span>);
    nameError.setAttribute(<span class="hljs-string">"aria-hidden"</span>, <span class="hljs-literal">false</span>);
    nameError.setAttribute(<span class="hljs-string">"aria-invalid"</span>, <span class="hljs-literal">true</span>);
  }
  <span class="hljs-keyword">return</span> valid;
}
</code></pre>
<pre><code class="lang-css"><span class="hljs-selector-id">#nameError</span> {
  <span class="hljs-attribute">display</span>: none;
  <span class="hljs-attribute">font-size</span>: <span class="hljs-number">0.8em</span>;
}

<span class="hljs-selector-id">#nameError</span><span class="hljs-selector-class">.visible</span> {
  <span class="hljs-attribute">display</span>: block;
}

<span class="hljs-selector-tag">input</span><span class="hljs-selector-class">.invalid</span> {
  <span class="hljs-attribute">border-color</span>: red;
}
</code></pre>
<p><a target="_blank" href="https://jsfiddle.net/0tq3e49w/4/">Link to JSFiddle</a></p>
<p>In this example, we check for required fields using JavaScript. If a required field is not present, we use CSS to show the error message. </p>
<p>Aria labels are modified accordingly to signal an error. By using CSS to show / hide an error, we are reducing the number of DOM manipulations we need to make. The error message is provided in-context thereby making the user experience intuitive.</p>
<h4 id="heading-html5-constraint-validation-api">HTML5 Constraint validation API</h4>
<p>The <code>required</code> and <code>pattern</code> HTML attributes can help perform basic validation. But if you want more complex validation or want to provide detailed error messaging, you can use the Constraint Validation API. </p>
<p>Some methods provided by this API are:</p>
<ol>
<li><code>checkValidity</code></li>
<li><code>setCustomValidity</code></li>
<li><code>reportValidity</code></li>
</ol>
<p>The following properties are useful:</p>
<ol>
<li><code>validity</code></li>
<li><code>validationMessage</code></li>
<li><code>willValidate</code></li>
</ol>
<p>In this example, we will validate using HTML5 inbuilt methods such as <code>required</code> and <code>length</code> in conjunction with the Constraint Validation API to provide detailed error messages.</p>
<pre><code class="lang-HTML"><span class="hljs-tag">&lt;<span class="hljs-name">form</span>&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-name">label</span> <span class="hljs-attr">for</span>=<span class="hljs-string">"firstname"</span>&gt;</span> First Name: <span class="hljs-tag">&lt;/<span class="hljs-name">label</span>&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-name">input</span> <span class="hljs-attr">type</span>=<span class="hljs-string">"text"</span> <span class="hljs-attr">name</span>=<span class="hljs-string">"firstname"</span> <span class="hljs-attr">required</span> <span class="hljs-attr">id</span>=<span class="hljs-string">"firstname"</span>&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-name">button</span>&gt;</span>Submit<span class="hljs-tag">&lt;/<span class="hljs-name">button</span>&gt;</span>
<span class="hljs-tag">&lt;/<span class="hljs-name">form</span>&gt;</span>
</code></pre>
<pre><code class="lang-javascript"><span class="hljs-keyword">const</span> nameField = <span class="hljs-built_in">document</span>.querySelector(<span class="hljs-string">"input"</span>);

nameField.addEventListener(<span class="hljs-string">"input"</span>, <span class="hljs-function">() =&gt;</span> {
  nameField.setCustomValidity(<span class="hljs-string">""</span>);
  nameField.checkValidity();
  <span class="hljs-built_in">console</span>.log(nameField.checkValidity());
});

nameField.addEventListener(<span class="hljs-string">"invalid"</span>, <span class="hljs-function">() =&gt;</span> {
  nameField.setCustomValidity(<span class="hljs-string">"Please fill in your First Name."</span>);
});
</code></pre>
<p><a target="_blank" href="https://jsfiddle.net/xz2wjLck/1/">Link to JSFiddle</a></p>
<h2 id="heading-dont-forget-server-side-validation">Don't forget server side validation</h2>
<p>Client side validation is not the only validation check you should do. You must also validate the data received from your client on the server side code to ensure that the data matches what you expect it to be. </p>
<p>You can also use server-side validation to perform business logic verifications that should not live on the client side.</p>
<h2 id="heading-form-validation-best-practices">Form Validation best practices</h2>
<ol>
<li>Always have server side validation, since malicious actors can bypass client side validation.</li>
<li>Provide detailed error messages in-context with the field that produced the error.</li>
<li>Provide an example of what the data should look like in case of an error message, such as - "Email did not match format - test@example.com"</li>
<li>Avoid using single error pages that involve redirection. This is bad user experience and forces the user to go back to a previous page to fix the form and lose context.</li>
<li>Always mark required fields.</li>
</ol>
<h3 id="heading-interested-in-more-tutorials-and-articles-like-this-sign-up-for-my-newsletterhttpstinylettercomshrutikapoor-or-follow-me-on-twitterhttpstwittercomshrutikapoor08">Interested in more tutorials and articles like this? <a target="_blank" href="https://tinyletter.com/shrutikapoor">Sign up for my newsletter.</a> or <a target="_blank" href="https://twitter.com/shrutikapoor08">follow me on Twitter</a></h3>
 ]]>
                </content:encoded>
            </item>
        
            <item>
                <title>
                    <![CDATA[ JavaScript Event Handlers – How to Handle Events in JS ]]>
                </title>
                <description>
                    <![CDATA[ What are events? Events are actions that happen when a user interacts with the page - like clicking an element, typing in a field, or loading a page.  The browser notifies the system that something has happened, and that it needs to be handled. It ge... ]]>
                </description>
                <link>https://www.freecodecamp.org/news/javascript-event-handlers/</link>
                <guid isPermaLink="false">66b99ced3cd81de09c96b2d1</guid>
                
                    <category>
                        <![CDATA[ events ]]>
                    </category>
                
                    <category>
                        <![CDATA[ JavaScript ]]>
                    </category>
                
                <dc:creator>
                    <![CDATA[ Shruti Kapoor ]]>
                </dc:creator>
                <pubDate>Mon, 21 Sep 2020 17:09:50 +0000</pubDate>
                <media:content url="https://www.freecodecamp.org/news/content/images/2020/09/samuel-pereira-uf2nnANWa8Q-unsplash.jpg" medium="image" />
                <content:encoded>
                    <![CDATA[ <h2 id="heading-what-are-events">What are events?</h2>
<p>Events are actions that happen when a user interacts with the page - like clicking an element, typing in a field, or loading a page. </p>
<p>The browser notifies the system that something has happened, and that it needs to be handled. It gets handled by registering a function, called an <code>event handler</code>, that listens for a particular type of event. </p>
<h2 id="heading-what-does-it-mean-to-handle-an-event">What does it mean to "handle an event"?</h2>
<p>To put it in simple terms, consider this - let's assume you are interested in attending Web Development meetup events in your local community. </p>
<p>To do this, you sign-up for a local meetup called "Women Who Code" and subscribe to notifications. This way, anytime a new meetup is scheduled, you get alerted. That is event handling! </p>
<p>The "event" here is a new JS meetup. When a new meetup is posted, the website meetup.com catches this change, thereby "handling" this event. It then notifies you, thus taking an "action" on the event. </p>
<p>In a browser, events are handled similarly. The browser detects a change, and alerts a function (event handler) that is listening to a particular event. These functions then perform the actions as desired. </p>
<p>Let's look at an example of a <code>click</code> event handler:</p>
<pre><code>&lt;div <span class="hljs-class"><span class="hljs-keyword">class</span></span>=<span class="hljs-string">"buttons"</span>&gt;
  <span class="xml"><span class="hljs-tag">&lt;<span class="hljs-name">button</span>&gt;</span>Press 1<span class="hljs-tag">&lt;/<span class="hljs-name">button</span>&gt;</span></span>
  <span class="xml"><span class="hljs-tag">&lt;<span class="hljs-name">button</span>&gt;</span>Press 2<span class="hljs-tag">&lt;/<span class="hljs-name">button</span>&gt;</span></span>
  <span class="xml"><span class="hljs-tag">&lt;<span class="hljs-name">button</span>&gt;</span>Press 3<span class="hljs-tag">&lt;/<span class="hljs-name">button</span>&gt;</span></span>
&lt;/div&gt;
<span class="hljs-keyword">const</span> buttonContainer = <span class="hljs-built_in">document</span>.querySelector(<span class="hljs-string">'.buttons'</span>);
<span class="hljs-built_in">console</span>.log(<span class="hljs-string">'buttonContainer'</span>, buttonContainer);

buttonContainer.addEventListener(<span class="hljs-string">'click'</span>, <span class="hljs-function"><span class="hljs-params">event</span> =&gt;</span> {
  <span class="hljs-built_in">console</span>.log(event.target.value)
})
</code></pre><h2 id="heading-what-are-the-different-types-of-events">What are the different types of events?</h2>
<p>An event can be triggered any time a user interacts with the page. These events could be a user scrolling through the page, clicking on an item, or loading a page. </p>
<p>Here are some common events - <code>onclick</code> <code>dblclick</code> <code>mousedown</code> <code>mouseup</code> <code>mousemove</code> <code>keydown</code> <code>keyup</code> <code>touchmove</code> <code>touchstart</code> <code>touchend</code> <code>onload</code> <code>onfocus</code> <code>onblur</code> <code>onerror</code> <code>onscroll</code> </p>
<h2 id="heading-different-phases-of-events-capture-target-bubble">Different phases of events - capture, target, bubble</h2>
<p>When an event moves through the DOM - whether bubbling up or trickling down - it is called event propagation. The event propagates through the DOM tree. </p>
<p>Events happen in two phases: the bubbling phase and the capturing phase. </p>
<p>In capture phase, also called the trickling phase, the event "trickles down" to the element that caused the event. </p>
<p>It starts from the root level element and handler, and then propagates down to the element. The capture phase is completed when the event reaches the <code>target</code>. </p>
<p>In the bubble phase, the event is "bubbled" up to the DOM tree. It is first captured and handled by the innermost handler (the one that is closest to the element on which the event occurred). It then bubbles up (or propagates up) to the higher levels of DOM tree, further up to its parents, and then finally to its root. </p>
<p>Her's a trick to help you remember this:</p>
<pre><code>trickle down, bubble up
</code></pre><p>Here's an infographic from <a target="_blank" href="https://www.quirksmode.org/js/events_order.html">quirksmode</a> that explains this very well: </p>
<pre><code>               / \
---------------| |-----------------
| element1     | |                |
|   -----------| |-----------     |
|   |element2  | |          |     |
|   -------------------------     |
|        Event BUBBLING           |
-----------------------------------

               | |
---------------| |-----------------
| element1     | |                |
|   -----------| |-----------     |
|   |element2  \ /          |     |
|   -------------------------     |
|        Event CAPTURING          |
-----------------------------------
</code></pre><p>One thing to note is that, whether you register an event handler in either phase, both phases ALWAYS happen. All events bubble by default. </p>
<p>You can register event handlers for either phase, bubbling or capturing, by using the function <code>addEventListener(type, listener, useCapture)</code>. If <code>useCapture</code> is set to <code>false</code>, the event handler is in the bubbling phase. Otherwise it's in the capture phase. </p>
<p>The order of the phases of the event depends on the browser.</p>
<p>To check which browser honors capture first, you can try the following code in JSfiddle: </p>
<pre><code class="lang-html"><span class="hljs-tag">&lt;<span class="hljs-name">div</span> <span class="hljs-attr">id</span>=<span class="hljs-string">"child-one"</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">h1</span>&gt;</span>
      Child One
    <span class="hljs-tag">&lt;/<span class="hljs-name">h1</span>&gt;</span>
  <span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span>
</code></pre>
<pre><code class="lang-javascript"><span class="hljs-keyword">const</span> childOne = <span class="hljs-built_in">document</span>.getElementById(<span class="hljs-string">"child-one"</span>);

<span class="hljs-keyword">const</span> childOneHandler = <span class="hljs-function">() =&gt;</span> {
<span class="hljs-built_in">console</span>.log(<span class="hljs-string">'Captured on child one'</span>)
}

<span class="hljs-keyword">const</span> childOneHandlerCatch = <span class="hljs-function">() =&gt;</span> {
<span class="hljs-built_in">console</span>.log(<span class="hljs-string">'Captured on child one in capture phase'</span>)
}

childOne.addEventListener(<span class="hljs-string">"click"</span>, childOneHandler); 
childOne.addEventListener(<span class="hljs-string">"click"</span>, childOneHandlerCatch, <span class="hljs-literal">true</span>);
</code></pre>
<p>In Firefox, Safari, and Chrome, the output is the following:
<img src="https://github.com/shrutikapoor08/blogs/blob/master/JSByte/img/events_capture_order.png?raw=true" alt="Events in capture phase are fired first" width="600" height="400" loading="lazy"> </p>
<h2 id="heading-how-to-listen-to-an-event">How to listen to an event</h2>
<p>There are two ways to listen to an event: </p>
<ol>
<li><code>addEventListener</code> </li>
<li><p>inline events, such as <code>onclick</code></p>
<p>```
//addEventListener
document.getElementByTag('a').addEventListener('click', onClickHandler);</p>
</li>
</ol>
<p>//inline using onclick
<a href="#">Click me</a></p>
<pre><code>
## Which is better - an inline event or <span class="hljs-string">`addEventListener`</span>?

<span class="hljs-number">1.</span> <span class="hljs-string">`addEventListener`</span> gives you the ability to register unlimited event handlers.
<span class="hljs-number">2.</span> <span class="hljs-string">`removeEventListener`</span> can also be used to remove event handlers
<span class="hljs-number">3.</span> The <span class="hljs-string">`useCapture`</span> flag can be used to indicate whether an event needs to be handled <span class="hljs-keyword">in</span> the capture phase or bundled phase.


## Code examples and live-action

You can <span class="hljs-keyword">try</span> out these events <span class="hljs-keyword">in</span> JSFiddle to play around <span class="hljs-keyword">with</span> them. 

<span class="hljs-string">``</span><span class="hljs-string">`html
&lt;div id="wrapper-div"&gt;
  &lt;div id="child-one"&gt;
    &lt;h1&gt;
      Child One
    &lt;/h1&gt;
  &lt;/div&gt;
  &lt;div id="child-two" onclick="childTwoHandler"&gt;
    &lt;h1&gt;
      Child Two
    &lt;/h1&gt;
  &lt;/div&gt;

&lt;/div&gt;</span>
</code></pre><pre><code class="lang-javascript"><span class="hljs-keyword">const</span> wrapperDiv = <span class="hljs-built_in">document</span>.getElementById(<span class="hljs-string">"wrapper-div"</span>);
<span class="hljs-keyword">const</span> childOne = <span class="hljs-built_in">document</span>.getElementById(<span class="hljs-string">"child-one"</span>);
<span class="hljs-keyword">const</span> childTwo = <span class="hljs-built_in">document</span>.getElementById(<span class="hljs-string">"child-two"</span>);

<span class="hljs-keyword">const</span> childOneHandler = <span class="hljs-function">() =&gt;</span> {
<span class="hljs-built_in">console</span>.log(<span class="hljs-string">'Captured on child one'</span>)
}

<span class="hljs-keyword">const</span> childTwoHandler = <span class="hljs-function">() =&gt;</span> {
<span class="hljs-built_in">console</span>.log(<span class="hljs-string">'Captured on child two'</span>)
}

<span class="hljs-keyword">const</span> wrapperDivHandler = <span class="hljs-function">() =&gt;</span> {
<span class="hljs-built_in">console</span>.log(<span class="hljs-string">'Captured on wrapper div'</span>)
}

<span class="hljs-keyword">const</span> childOneHandlerCatch = <span class="hljs-function">() =&gt;</span> {
<span class="hljs-built_in">console</span>.log(<span class="hljs-string">'Captured on child one in capture phase'</span>)
}

<span class="hljs-keyword">const</span> childTwoHandlerCatch = <span class="hljs-function">() =&gt;</span> {
<span class="hljs-built_in">console</span>.log(<span class="hljs-string">'Captured on child two in capture phase'</span>)
}

<span class="hljs-keyword">const</span> wrapperDivHandlerCatch = <span class="hljs-function">() =&gt;</span> {
<span class="hljs-built_in">console</span>.log(<span class="hljs-string">'Captured on wrapper div in capture phase'</span>)
}


childOne.addEventListener(<span class="hljs-string">"click"</span>, childOneHandler); 
childTwo.addEventListener(<span class="hljs-string">"click"</span>, childTwoHandler); 
wrapperDiv.addEventListener(<span class="hljs-string">"click"</span>, wrapperDivHandler); 

childOne.addEventListener(<span class="hljs-string">"click"</span>, childOneHandlerCatch, <span class="hljs-literal">true</span>); 
childTwo.addEventListener(<span class="hljs-string">"click"</span>, childTwoHandlerCatch, <span class="hljs-literal">true</span>); 
wrapperDiv.addEventListener(<span class="hljs-string">"click"</span>, wrapperDivHandlerCatch, <span class="hljs-literal">true</span>);
</code></pre>
<h2 id="heading-tldr">TL;DR</h2>
<p>Event phases are capture (DOM -&gt; target), bubble (target-&gt; DOM) and target. 
Events can be listened for by using <code>addEventListener</code> or inline methods such as <code>onclick</code>. </p>
<pre><code>    addEventListener can add multiple events, whereas <span class="hljs-keyword">with</span> onclick <span class="hljs-built_in">this</span> cannot be done.
    onclick can be added <span class="hljs-keyword">as</span> an HTML attribute, whereas an addEventListener can only be added within &lt;script&gt; elements.
    addEventListener can take a third argument which can stop the event propagation.
</code></pre><h2 id="heading-futher-reading">Futher reading</h2>
<p>https://www.quirksmode.org/js/events_order.html
https://jsfiddle.net/r2bc6axg/
https://stackoverflow.com/questions/6348494/addeventlistener-vs-onclick
https://www.w3.org/wiki/HTML/Attributes/_Global#Event-handler_Attributes</p>
<p>To keep up with more short tutorials like this, <a target="_blank" href="https://tinyletter.com/shrutikapoor">sign up for my newsletter</a> or <a target="_blank" href="https://twitter.com/shrutikapoor08">follow me on Twitter</a></p>
 ]]>
                </content:encoded>
            </item>
        
            <item>
                <title>
                    <![CDATA[ JavaScript Optional Chaining `?.` Explained - How it Works and When to Use it ]]>
                </title>
                <description>
                    <![CDATA[ What is optional chaining? Optional chaining, represented by ?. in JavaScript, is a new feature introduced in ES2020.  Optional chaining changes the way properties are accessed from deeply nested objects. It fixes the problem of having to do multiple... ]]>
                </description>
                <link>https://www.freecodecamp.org/news/javascript-optional-chaining-explained/</link>
                <guid isPermaLink="false">66b99cf194b336889c600476</guid>
                
                    <category>
                        <![CDATA[ Babel ]]>
                    </category>
                
                    <category>
                        <![CDATA[ JavaScript ]]>
                    </category>
                
                <dc:creator>
                    <![CDATA[ Shruti Kapoor ]]>
                </dc:creator>
                <pubDate>Tue, 25 Aug 2020 15:39:34 +0000</pubDate>
                <media:content url="https://cdn-media-2.freecodecamp.org/w1280/5f9c990e740569d1a4ca1d97.jpg" medium="image" />
                <content:encoded>
                    <![CDATA[ <h2 id="heading-what-is-optional-chaining">What is optional chaining?</h2>
<p>Optional chaining, represented by <code>?.</code> in JavaScript, is a new feature introduced in ES2020. </p>
<p>Optional chaining changes the way properties are accessed from deeply nested objects. It fixes the problem of having to do multiple null checks when accessing a long chain of object properties in JavaScript.</p>
<p>Current Status: <code>ECMAScript proposal at stage 4 of the process.</code> : https://github.com/tc39/proposal-optional-chaining</p>
<h2 id="heading-use-cases">Use cases</h2>
<ol>
<li>Accessing potentially <code>null</code> or <code>undefined</code> properties of an object. </li>
<li>Getting results from a variable that may not be available yet.</li>
<li>Getting default values.</li>
<li>Accessing long chains of properties.</li>
</ol>
<p>Imagine you are expecting an API to return an object of this sort:</p>
<pre><code class="lang-javascript">obj = {
  <span class="hljs-attr">prop1</span>: {
    <span class="hljs-attr">prop2</span>: {
      <span class="hljs-attr">someProp</span>: <span class="hljs-string">"value"</span>
    }
  }
};
</code></pre>
<p>But you may not know if each of these fields are available ahead of time. Some of them may not have been sent back by the API, or they may have come back with null values. </p>
<p>Here is an example:</p>
<pre><code class="lang-javascript"><span class="hljs-comment">//expected</span>
obj = {
  <span class="hljs-attr">id</span>: <span class="hljs-number">9216</span>,
  <span class="hljs-attr">children</span>: [
    { <span class="hljs-attr">id</span>: <span class="hljs-number">123</span>, <span class="hljs-attr">children</span>: <span class="hljs-literal">null</span> },
    { <span class="hljs-attr">id</span>: <span class="hljs-number">124</span>, <span class="hljs-attr">children</span>: [{ <span class="hljs-attr">id</span>: <span class="hljs-number">1233</span>, <span class="hljs-attr">children</span>: <span class="hljs-literal">null</span> }] }
  ]
};

<span class="hljs-comment">//actual</span>
obj = {
  <span class="hljs-attr">id</span>: <span class="hljs-number">9216</span>,
  <span class="hljs-attr">children</span>: <span class="hljs-literal">null</span>
};
</code></pre>
<p>This happens very often with functions that call APIs. You may have seen code in React that tries to safeguard against these issues like this:</p>
<pre><code class="lang-jsx">render = <span class="hljs-function">() =&gt;</span> {
  <span class="hljs-keyword">const</span> obj = {
    <span class="hljs-attr">prop1</span>: {
      <span class="hljs-attr">prop2</span>: {
        <span class="hljs-attr">someProp</span>: <span class="hljs-string">"value"</span>,
      },
    },
  };

  <span class="hljs-keyword">return</span> (
    <span class="xml"><span class="hljs-tag">&lt;<span class="hljs-name">div</span>&gt;</span>
      {obj &amp;&amp; obj.prop1 &amp;&amp; obj.prop1.prop2 &amp;&amp; obj.prop1.prop2.someProp &amp;&amp; (
        <span class="hljs-tag">&lt;<span class="hljs-name">div</span>&gt;</span>{obj.prop1.prop2.someProp}<span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span>
      )}
    <span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span></span>
  );
};
</code></pre>
<p>In order to better prepare for this issue, often times in the past we have used <code>Lodash</code>, specifically the <code>_.get</code> method:</p>
<pre><code class="lang-javascript">_.get(obj, prop1.prop2.someProp);
</code></pre>
<p>This outputs <code>undefined</code> if either of those properties are <code>undefined</code>. <strong>Optional chaining is exactly that</strong>! Now instead of using an external library, this functionality is built-in.</p>
<h2 id="heading-how-does-optional-chaining-work">How does optional chaining work?</h2>
<p><code>?.</code> can be used to chain properties that may be <code>null</code> or <code>undefined</code>.</p>
<pre><code><span class="hljs-keyword">const</span> propNeeded = obj?.prop1?.prop2?.someProp;
</code></pre><p>If either of those chained properties is <code>null</code> or <code>undefined</code>, JavaScript will return <code>undefined</code>. </p>
<p>What if we want to return something meaningful? Try this: </p>
<pre><code class="lang-javascript"><span class="hljs-keyword">let</span> familyTree = {
    <span class="hljs-attr">us</span>: {
        <span class="hljs-attr">children</span>: {}
    }
}


<span class="hljs-comment">// with _.get</span>
<span class="hljs-keyword">const</span> grandChildren = _.get(familyTree, <span class="hljs-string">'us.children.theirChildren'</span>, <span class="hljs-string">'got no kids'</span> );

<span class="hljs-comment">//with optional chaining and null coalescing </span>
<span class="hljs-keyword">const</span> nullCoalescing = familyTree?.us?.children?.theirChildren ?? <span class="hljs-string">'got no kids'</span>
<span class="hljs-built_in">console</span>.log(nullCoalescing) <span class="hljs-comment">//got no kids</span>
</code></pre>
<p>It also works for objects that may be <code>null</code> or <code>undefined</code>:</p>
<pre><code><span class="hljs-keyword">let</span> user;
<span class="hljs-built_in">console</span>.log(user?.id) <span class="hljs-comment">// undefined</span>
</code></pre><h2 id="heading-how-to-get-this-newest-feature">How to get this newest feature</h2>
<ol>
<li><p>Try it in your browser's console: This is a recent addition and old browsers may need polyfills. You can try it in Chrome or Firefox in the browser's console. If it doesn't work, try turning on JavaScript experimental features by visiting <code>chrome://flags/</code> and enabling "Experimental JavaScript".</p>
</li>
<li><p>Try it in your Node app by using Babel:</p>
<pre><code>{
<span class="hljs-string">"plugins"</span>: [<span class="hljs-string">"@babel/plugin-proposal-optional-chaining"</span>]
}
</code></pre></li>
</ol>
<h2 id="heading-resources">Resources</h2>
<ol>
<li>https://dmitripavlutin.com/javascript-optional-chaining/</li>
<li>Babel's doc: https://babeljs.io/docs/en/babel-plugin-proposal-optional-chaining</li>
</ol>
<h2 id="heading-tldr">TL;DR</h2>
<p>Use optional chaining <code>?.</code> for objects or long chain properties that may be <code>null</code> or <code>undefined</code>. The syntax is as follows:</p>
<pre><code class="lang-javascript"><span class="hljs-keyword">let</span> user = {};
<span class="hljs-built_in">console</span>.log(user?.id?.name)
</code></pre>
<hr>
<p>Interested in more tutorials and JSBytes from me? <a target="_blank" href="https://tinyletter.com/shrutikapoor">Sign up for my newsletter.</a> or <a target="_blank" href="https://twitter.com/shrutikapoor08">follow me on Twitter</a></p>
 ]]>
                </content:encoded>
            </item>
        
            <item>
                <title>
                    <![CDATA[ JavaScript Array Slice vs Splice: the Difference Explained with Cake ]]>
                </title>
                <description>
                    <![CDATA[ This title could have been "how not to get confused between JavaScript's splice and slice," because I can never remember the difference between the two.  So I am hoping this trick will help both me and you in the future: S (p) lice = Slice + (p) => S... ]]>
                </description>
                <link>https://www.freecodecamp.org/news/javascript-array-slice-vs-splice-whats-the-difference/</link>
                <guid isPermaLink="false">66b99ceabe5923657131acf3</guid>
                
                    <category>
                        <![CDATA[ arrays ]]>
                    </category>
                
                    <category>
                        <![CDATA[ JavaScript ]]>
                    </category>
                
                <dc:creator>
                    <![CDATA[ Shruti Kapoor ]]>
                </dc:creator>
                <pubDate>Tue, 11 Aug 2020 16:03:17 +0000</pubDate>
                <media:content url="https://www.freecodecamp.org/news/content/images/2020/08/dilyara-garifullina-I48gnI1Qs5o-unsplash.jpg" medium="image" />
                <content:encoded>
                    <![CDATA[ <p>This title could have been "how not to get confused between JavaScript's splice and slice," because I can never remember the difference between the two. </p>
<p>So I am hoping this trick will help both me and you in the future:</p>
<pre><code>S (p) lice = Slice + <span class="hljs-function">(<span class="hljs-params">p</span>) =&gt;</span> Slice + <span class="hljs-keyword">in</span> (p) lace
</code></pre><h2 id="heading-arrayprototypeslice">Array.prototype.slice()</h2>
<p>Array.prototype.slice() is used to slice an array from the <code>start</code> point to the <code>end</code> point, excluding the <code>end</code>. </p>
<p>As the name suggests, it is used to slice elements out of an array. But unlike slicing a cake, slicing an array does not cut the actual array, but keeps it unmodified (infinite cake!). </p>
<pre><code class="lang-JS">arr.slice(start, [end])
</code></pre>
<p>Rules</p>
<ol>
<li>A new array is returned and the original array is unmodified. </li>
<li>If <code>end</code> is omitted, end becomes the end (last element) of the array. </li>
<li>If <code>start</code> is -ve, the elements are counted from the end.</li>
</ol>
<pre><code class="lang-JS"><span class="hljs-keyword">const</span> infiniteCake = [<span class="hljs-string">'?'</span>,<span class="hljs-string">'?'</span>,<span class="hljs-string">'?'</span>,<span class="hljs-string">'?'</span>,<span class="hljs-string">'?'</span>,<span class="hljs-string">'?'</span>]

<span class="hljs-keyword">let</span> myPieceOfCake = infiniteCake.slice(<span class="hljs-number">0</span>,<span class="hljs-number">1</span>) <span class="hljs-comment">// ['?']</span>
<span class="hljs-keyword">let</span> yourDoublePieceOfCake = infiniteCake.slice(<span class="hljs-number">0</span>,<span class="hljs-number">2</span>) <span class="hljs-comment">// (2) ["?", "?"]</span>
<span class="hljs-built_in">console</span>.log(infiniteCake) <span class="hljs-comment">//['?','?','?','?','?','?']</span>
</code></pre>
<p>As you see, <code>inifinteCake</code> is unmodified.</p>
<h2 id="heading-arrayprototypesplice">Array.prototype.splice()</h2>
<p>Splice does operations <strong>in place</strong>, which means it modifies the exisiting array. </p>
<p>In addition to removing elements, splice is also used to add elements. Splice is the real world cake "slice":</p>
<pre><code class="lang-JS">arr.splice(start, [deleteCount, itemToInsert1, itemToInsert2, ...])
</code></pre>
<p>Rules</p>
<ol>
<li>Operations are performed in place. </li>
<li>An array is returned with the deleted items. </li>
<li>If <code>start</code> is -ve, the elements are counted from the end.</li>
<li>If <code>deleteCount</code>is omitted,the elements until the end of the array are removed.</li>
<li>If items to insert such as <code>itemToInsert1</code> are omitted, elements are only removed.</li>
</ol>
<pre><code class="lang-JS"><span class="hljs-keyword">const</span> cake = [<span class="hljs-string">'?'</span>,<span class="hljs-string">'?'</span>,<span class="hljs-string">'?'</span>,<span class="hljs-string">'?'</span>,<span class="hljs-string">'?'</span>,<span class="hljs-string">'?'</span>];
<span class="hljs-keyword">let</span> myPieceOfCake = cake.splice(<span class="hljs-number">0</span>, <span class="hljs-number">1</span>) <span class="hljs-comment">// ["?"]</span>
<span class="hljs-built_in">console</span>.log(cake) <span class="hljs-comment">// (5) ["?", "?", "?", "?", "?"]</span>

<span class="hljs-keyword">let</span> yourDoublePieceOfCake = cake.splice(<span class="hljs-number">0</span>,<span class="hljs-number">2</span>) <span class="hljs-comment">//(2) ["?", "?"]</span>
<span class="hljs-built_in">console</span>.log(cake) <span class="hljs-comment">//(3) ["?", "?", "?"]</span>
</code></pre>
<p>Here, <code>cake</code> is modified and reduces in size. </p>
<h2 id="heading-code-examples">Code Examples</h2>
<pre><code class="lang-JS"><span class="hljs-keyword">const</span> myArray  = [<span class="hljs-number">1</span>,<span class="hljs-number">2</span>,<span class="hljs-number">3</span>,<span class="hljs-number">4</span>,<span class="hljs-number">5</span>,<span class="hljs-number">6</span>,<span class="hljs-number">7</span>] 

<span class="hljs-built_in">console</span>.log(myArray.slice(<span class="hljs-number">0</span>))       <span class="hljs-comment">// [ 1, 2, 3, 4, 5, 6, 7 ]</span>
<span class="hljs-built_in">console</span>.log(myArray.slice(<span class="hljs-number">0</span>, <span class="hljs-number">1</span>))    <span class="hljs-comment">// [ 1 ]</span>
<span class="hljs-built_in">console</span>.log(myArray.slice(<span class="hljs-number">1</span>))       <span class="hljs-comment">// [ 2, 3, 4, 5, 6, 7 ]</span>
<span class="hljs-built_in">console</span>.log(myArray.slice(<span class="hljs-number">5</span>))       <span class="hljs-comment">// [ 6, 7 ]</span>
<span class="hljs-built_in">console</span>.log(myArray.slice(<span class="hljs-number">-1</span>))      <span class="hljs-comment">// [ 7 ]</span>
<span class="hljs-built_in">console</span>.log(myArray)                <span class="hljs-comment">// [ 1, 2, 3, 4, 5, 6, 7 ]</span>



<span class="hljs-keyword">const</span> secondArray = [<span class="hljs-number">10</span>, <span class="hljs-number">20</span>, <span class="hljs-number">30</span>, <span class="hljs-number">40</span>, <span class="hljs-number">50</span>]

<span class="hljs-built_in">console</span>.log(secondArray.splice(<span class="hljs-number">0</span>, <span class="hljs-number">1</span>))   <span class="hljs-comment">// [ 10 ] : deletes 1 element starting at index 0</span>
<span class="hljs-built_in">console</span>.log(secondArray.splice(<span class="hljs-number">-2</span>, <span class="hljs-number">1</span>))  <span class="hljs-comment">// [ 40 ] : deletes 1 element starting at index end-2 </span>
<span class="hljs-built_in">console</span>.log(secondArray)                <span class="hljs-comment">// [ 20, 30, 50 ]</span>
<span class="hljs-built_in">console</span>.log(secondArray.splice(<span class="hljs-number">0</span>))      <span class="hljs-comment">// [ 20, 30, 50 ] : deletes all elements starting at index 0</span>
<span class="hljs-built_in">console</span>.log(secondArray)                <span class="hljs-comment">// []</span>
<span class="hljs-built_in">console</span>.log(secondArray.splice(<span class="hljs-number">2</span>, <span class="hljs-number">0</span>, <span class="hljs-number">60</span>, <span class="hljs-number">70</span>)) <span class="hljs-comment">// [] : deletes 0 elements starting at index 2 (doesn't exist so defaults to 0) and then inserts 60, 70</span>
<span class="hljs-built_in">console</span>.log(secondArray)                <span class="hljs-comment">// [60, 70]</span>
</code></pre>
<h2 id="heading-tldr">TL;DR</h2>
<p>Use <code>splice</code> if the original array needs to be modified, or elements need to be added.</p>
<p>Use <code>slice</code> for removing elements if the original array should not be modified.</p>
<hr>
<p>Interested in more tutorials and JSBytes from me? <a target="_blank" href="https://tinyletter.com/shrutikapoor">Sign up for my newsletter.</a> or <a target="_blank" href="https://twitter.com/shrutikapoor08">follow me on Twitter</a></p>
 ]]>
                </content:encoded>
            </item>
        
            <item>
                <title>
                    <![CDATA[ JavaScript URL Encode Example – How to Use encodeURIcomponent() and encodeURI() ]]>
                </title>
                <description>
                    <![CDATA[ You might think that encodeURI and encodeURIComponent do the same thing, at least from their names. And you might be confused which one to use and when. In this article, I will demystify the difference between encodeURI and encodeURIComponent.  What ... ]]>
                </description>
                <link>https://www.freecodecamp.org/news/javascript-url-encode-example-how-to-use-encodeuricomponent-and-encodeuri/</link>
                <guid isPermaLink="false">66b99cf7489480391dfe7a4a</guid>
                
                    <category>
                        <![CDATA[ browser ]]>
                    </category>
                
                    <category>
                        <![CDATA[ JavaScript ]]>
                    </category>
                
                <dc:creator>
                    <![CDATA[ Shruti Kapoor ]]>
                </dc:creator>
                <pubDate>Tue, 04 Aug 2020 22:39:13 +0000</pubDate>
                <media:content url="https://www.freecodecamp.org/news/content/images/2020/08/richy-great-MAYEkmn7G6E-unsplash.jpg" medium="image" />
                <content:encoded>
                    <![CDATA[ <p>You might think that <code>encodeURI</code> and <code>encodeURIComponent</code> do the same thing, at least from their names. And you might be confused which one to use and when.</p>
<p>In this article, I will demystify the difference between <code>encodeURI</code> and <code>encodeURIComponent</code>. </p>
<h3 id="heading-what-is-a-uri-and-how-is-it-different-from-a-url">What is a URI and how is it different from a URL?</h3>
<p><strong>URI</strong> stands for Uniform Resource Identifier.
<strong>URL</strong> stands for Uniform Resource Locator.</p>
<p>Anything that uniquely identifies a resource is its URI, such as id, name, or ISBN number. A URL specifies a resource and how it can be accessed (the protocol).  All URLs are URIs, but not all URIs are URLs.</p>
<h3 id="heading-why-do-we-need-to-encode">Why do we need to encode?</h3>
<p>URLs can only have certain characters from the standard 128 character ASCII set. Reserved characters that do not belong to this set must be encoded. </p>
<p>This means that we need to encode these characters when passing into a URL. Special characters such as <code>&amp;</code>, <code>space</code>, <code>!</code> when entered in a url need to be escaped, otherwise they may cause unpredictable situations. </p>
<p>Use cases:</p>
<ol>
<li>User has submitted values in a form that may be in a string format and need to be passed in, such as URL fields. </li>
<li>Need to accept query string parameters in order to make GET requests.</li>
</ol>
<h3 id="heading-what-is-the-difference-between-encodeuri-and-encodeuricomponent">What is the difference between encodeURI and encodeURIComponent?</h3>
<p><code>encodeURI</code> and <code>encodeURIComponent</code> are used to encode Uniform Resource Identifiers (URIs) by replacing certain characters by one, two, three or four escape sequences representing the UTF-8 encoding of the character.</p>
<p><code>encodeURIComponent</code> should be used to encode a <strong>URI</strong> <strong>Component</strong> - a string that is supposed to be part of a URL.</p>
<p><code>encodeURI</code> should be used to encode a <strong>URI</strong> or an existing URL. </p>
<p><a target="_blank" href="https://stackoverflow.com/a/23842171">Here's a handy table of the difference in encoding of characters</a></p>
<h3 id="heading-which-characters-are-encoded">Which characters are encoded?</h3>
<p><code>encodeURI()</code> will not encode: <code>~!@#$&amp;*()=:/,;?+'</code></p>
<p><code>encodeURIComponent()</code> will not encode: <code>~!*()'</code></p>
<p>The characters <code>A-Z a-z 0-9 - _ . ! ~ * ' ( )</code> are not escaped. </p>
<h3 id="heading-examples">Examples</h3>
<pre><code class="lang-JS"><span class="hljs-keyword">const</span> url = <span class="hljs-string">'https://www.twitter.com'</span>

<span class="hljs-built_in">console</span>.log(<span class="hljs-built_in">encodeURI</span>(url))             <span class="hljs-comment">//https://www.twitter.com</span>
<span class="hljs-built_in">console</span>.log(<span class="hljs-built_in">encodeURIComponent</span>(url))    <span class="hljs-comment">//https%3A%2F%2Fwww.twitter.com</span>


<span class="hljs-keyword">const</span> paramComponent = <span class="hljs-string">'?q=search'</span>
<span class="hljs-built_in">console</span>.log(<span class="hljs-built_in">encodeURIComponent</span>(paramComponent)) <span class="hljs-comment">//"%3Fq%3Dsearch"</span>
<span class="hljs-built_in">console</span>.log(url + <span class="hljs-built_in">encodeURIComponent</span>(paramComponent)) <span class="hljs-comment">//https://www.twitter.com%3Fq%3Dsearch</span>
</code></pre>
<h3 id="heading-when-to-encode">When to encode</h3>
<ol>
<li>When accepting an input that may have spaces.<pre><code class="lang-JS"> <span class="hljs-built_in">encodeURI</span>(<span class="hljs-string">"http://www.mysite.com/a file with spaces.html"</span>) <span class="hljs-comment">//http://www.mysite.com/a%20file%20with%20spaces.html</span>
</code></pre>
</li>
<li><p>When building a URL from query string parameters.</p>
<pre><code class="lang-JS"> <span class="hljs-keyword">let</span> param = <span class="hljs-built_in">encodeURIComponent</span>(<span class="hljs-string">'mango'</span>)
 <span class="hljs-keyword">let</span> url = <span class="hljs-string">"http://mysite.com/?search="</span> + param + <span class="hljs-string">"&amp;length=99"</span>; <span class="hljs-comment">//http://mysite.com/?search=mango&amp;length=99</span>
</code></pre>
</li>
<li><p>When accepting query parameters that may have reserved characters.
```JS
 let params = encodeURIComponent('mango &amp; pineapple')
 let url = "http://mysite.com/?search=" + params; //http://mysite.com/?search=mango%20%26%20pineapple</p>
</li>
</ol>
<p>   ```</p>
<h3 id="heading-summary">Summary</h3>
<p>If you have a complete URL, use <code>encodeURI</code>. But if you have a part of a URL, use <code>encodeURIComponent</code>. </p>
<hr>
<p>Interested in more tutorials and JSBytes from me? <a target="_blank" href="https://tinyletter.com/shrutikapoor">Sign up for my newsletter.</a> or <a target="_blank" href="https://twitter.com/shrutikapoor08">follow me on Twitter</a></p>
<p>### </p>
 ]]>
                </content:encoded>
            </item>
        
            <item>
                <title>
                    <![CDATA[ The Access-Control-Allow-Origin Header Explained – With a CORS Example ]]>
                </title>
                <description>
                    <![CDATA[ Often times when calling an API, you may see an error in your console that looks like this: Access to fetch at 'http://somesite.com' from origin 'http://yoursite.com' has been blocked by CORS policy: The 'Access-Control-Allow-Origin' header has a va... ]]>
                </description>
                <link>https://www.freecodecamp.org/news/access-control-allow-origin-header-explained/</link>
                <guid isPermaLink="false">66b99cc53cd81de09c96b2ca</guid>
                
                    <category>
                        <![CDATA[ CORS ]]>
                    </category>
                
                    <category>
                        <![CDATA[ JavaScript ]]>
                    </category>
                
                <dc:creator>
                    <![CDATA[ Shruti Kapoor ]]>
                </dc:creator>
                <pubDate>Fri, 17 Jul 2020 07:18:00 +0000</pubDate>
                <media:content url="https://cdn-media-2.freecodecamp.org/w1280/5f9c99aa740569d1a4ca210e.jpg" medium="image" />
                <content:encoded>
                    <![CDATA[ <p>Often times when calling an API, you may see an error in your console that looks like this:</p>
<pre><code>
Access to fetch at <span class="hljs-string">'http://somesite.com'</span> <span class="hljs-keyword">from</span> origin <span class="hljs-string">'http://yoursite.com'</span> has been blocked by CORS policy: The <span class="hljs-string">'Access-Control-Allow-Origin'</span> header has a value that is not equal to the supplied origin
</code></pre><p>In this post, we are going to learn why this error happens and how you can fix it. </p>
<h2 id="heading-what-is-the-access-control-allow-origin-header">What is the <code>Access-Control-Allow-Origin</code> header?</h2>
<p><code>Access-Control-Allow-Origin</code> is a CORS header. CORS, or Cross Origin Resource Sharing, is a mechanism for browsers to let a site running at origin A to request resources from origin B. </p>
<p>Origin is not just the hostname, but a combination of port, hostname and scheme, such as - <code>http://mysite.example.com:8080/</code></p>
<p>Here's an example of where this comes into action - </p>
<ol>
<li>I have an origin A: <code>http://mysite.com</code> and I want to get resources from origin B: <code>http://yoursite.com</code>. </li>
<li>To protect your security, the browser will not let me access resources from yoursite.com and will block my request. </li>
<li>In order to allow origin A to access your resources, your origin B will need to let the browser know that it is okay for me to get resources from your origin.</li>
</ol>
<p>Here is an example from Mozilla Developer Network that explains this really well:</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2020/07/CORS_principle.png" alt="Image" width="600" height="400" loading="lazy"></p>
<p>With the help of CORS, browsers allow origins to share resources amongst each other. </p>
<p>There are a <a target="_blank" href="https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS#The_HTTP_response_headers">few headers</a> that allow sharing of resources across origins, but the main one is  <code>Access-Control-Allow-Origin</code>. This tells the browser what origins are allowed to receive requests from this server. </p>
<h2 id="heading-who-needs-to-set-access-control-allow-origin">Who needs to set <code>Access-Control-Allow-Origin</code>?</h2>
<p>To understand who needs to set this header, consider this scenario: You are browsing a website that is used to view and listen to songs. The website attempts to make a connection to your bank in the background maliciously. </p>
<p>So who has the ultimate ability to prevent this malicious website from stealing your data from the bank? The bank! So, the bank will need to protect its resources by setting the <code>Access-Control-Allow-Origin</code> header as part of the response.</p>
<p>Just remember: the origin responsible for serving resources will need to set this header.</p>
<h2 id="heading-how-to-use-and-when-to-pass-this-header">How to use and when to pass this header</h2>
<p>Here's an example of values you can set: </p>
<ol>
<li><code>Access-Control-Allow-Origin : *</code> : Allows any origin.</li>
<li><code>Access-Control-Allow-Origin : http://mysite.com</code> : Allow requests only from mysite.com.</li>
</ol>
<h2 id="heading-see-it-in-action">See it in action</h2>
<p>Let's look at an example. You can check out this code <a target="_blank" href="https://github.com/shrutikapoor08/blogs/tree/master/code-examples/CORS">on my GitHub repo</a>. </p>
<p>We are going to build a server on origin A <code>http://localhost:8000</code> which will send a string of <code>Hello</code>s to an <code>api</code> endpoint. We are going to call with this endpoint by creating a client on origin B <code>http://localhost:3000</code> and then use fetch to request the resource. We expect to see the string <code>Hello</code> passed by origin A in the browser console of origin B. </p>
<p>Let's say we have an origin up on <code>http://localhost:8000</code> that serves up this resource on <code>/api</code> endpoint. The server sends a response with the header <code>Access-Control-Allow-Origin</code>.</p>
<pre><code><span class="hljs-keyword">const</span> express = <span class="hljs-built_in">require</span>(<span class="hljs-string">"express"</span>);

<span class="hljs-keyword">const</span> app = express();
<span class="hljs-keyword">const</span> port = process.env.SERVER_PORT || <span class="hljs-number">8000</span>;

<span class="hljs-comment">// Add Access Control Allow Origin headers</span>
app.use(<span class="hljs-function">(<span class="hljs-params">req, res, next</span>) =&gt;</span> {
  res.setHeader(<span class="hljs-string">"Access-Control-Allow-Origin"</span>, <span class="hljs-string">"https://yoursite.com"</span>);
  res.header(
    <span class="hljs-string">"Access-Control-Allow-Headers"</span>,
    <span class="hljs-string">"Origin, X-Requested-With, Content-Type, Accept"</span>
  );
  next();
});

app.get(<span class="hljs-string">"/api"</span>, <span class="hljs-function">(<span class="hljs-params">req, res</span>) =&gt;</span> {
  res.json(<span class="hljs-string">"Hello"</span>);
});

app.listen(port, <span class="hljs-function">() =&gt;</span> <span class="hljs-built_in">console</span>.log(<span class="hljs-string">`Listening on port <span class="hljs-subst">${port}</span>`</span>));
</code></pre><p>On the client side, you can call this endpoint by calling <code>fetch</code> like this: </p>
<pre><code>fetch(<span class="hljs-string">'http://localhost:8000/api'</span>)
.then(<span class="hljs-function"><span class="hljs-params">res</span> =&gt;</span> res.json())
.then(<span class="hljs-function"><span class="hljs-params">res</span> =&gt;</span> <span class="hljs-built_in">console</span>.log(res));
</code></pre><p>Now open your browser's console to see the result. 
Since the header is currently set to allow access only from <code>https://yoursite.com</code>, the browser will block access to the resource and you will see an error in your console.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2020/07/CORS-access-denied.png" alt="Image" width="600" height="400" loading="lazy"></p>
<p>Now, to fix this, change the headers to this:</p>
<pre><code> res.setHeader(<span class="hljs-string">"Access-Control-Allow-Origin"</span>, <span class="hljs-string">"*"</span>);
</code></pre><p>Check your browser's console and now you will be able to see the string <code>Hello</code>.</p>
<h3 id="heading-interested-in-more-tutorials-and-jsbytes-from-me-sign-up-for-my-newsletter">Interested in more tutorials and JSBytes from me? Sign up for my newsletter.</h3>
 ]]>
                </content:encoded>
            </item>
        
            <item>
                <title>
                    <![CDATA[ How to Use Fetch to Make AJAX Calls in JavaScript ]]>
                </title>
                <description>
                    <![CDATA[ I will be sharing bite sized learnings about JavaScript regularly in this series. We'll cover JS fundamentals, browsers, DOM, system design, domain architecture and frameworks. Fetch is an interface for making an AJAX request in JavaScript. It is imp... ]]>
                </description>
                <link>https://www.freecodecamp.org/news/how-to-use-fetch-api/</link>
                <guid isPermaLink="false">66b99ce79bb332ccb182f7fb</guid>
                
                    <category>
                        <![CDATA[ 100DaysOfCode ]]>
                    </category>
                
                    <category>
                        <![CDATA[ beginner ]]>
                    </category>
                
                    <category>
                        <![CDATA[ Front-end Development ]]>
                    </category>
                
                    <category>
                        <![CDATA[ JavaScript ]]>
                    </category>
                
                <dc:creator>
                    <![CDATA[ Shruti Kapoor ]]>
                </dc:creator>
                <pubDate>Fri, 26 Jun 2020 17:43:31 +0000</pubDate>
                <media:content url="https://cdn-media-2.freecodecamp.org/w1280/5f9c9a08740569d1a4ca231d.jpg" medium="image" />
                <content:encoded>
                    <![CDATA[ <p>I will be sharing bite sized learnings about JavaScript regularly in this series. We'll cover JS fundamentals, browsers, DOM, system design, domain architecture and frameworks.</p>
<p>Fetch is an interface for making an AJAX request in JavaScript. It is implemented widely by modern browsers and is used to call an API. </p>
<pre><code class="lang-javascript"><span class="hljs-keyword">const</span> promise = fetch(url, [options])
</code></pre>
<p>Calling fetch returns a promise, with a Response object. The promise is rejected if there is a network error, and it's resolved if there is no problem connecting to the server and the server responded a status code. This status code could be 200s, 400s or 500s.</p>
<p>A sample FETCH request - </p>
<pre><code class="lang-javascript">
fetch(url)
  .then(<span class="hljs-function"><span class="hljs-params">response</span> =&gt;</span> response.json())
  .catch(<span class="hljs-function"><span class="hljs-params">err</span> =&gt;</span> <span class="hljs-built_in">console</span>.log(err))
</code></pre>
<p>The request is sent as a GET by default. To send a POST / PATCH / DELETE / PUT you can use the method property as part of <code>options</code> parameter. Some other possible values <code>options</code> can take - </p>
<ul>
<li><code>method</code>:  such as GET, POST, PATCH</li>
<li><code>headers</code>: Headers object</li>
<li><code>mode</code>:  such as <code>cors</code>, <code>no-cors</code>, <code>same-origin</code></li>
<li><code>cache</code>: cache mode for request</li>
<li><code>credentials</code></li>
<li><code>body</code></li>
</ul>
<p><a target="_blank" href="'https://developer.mozilla.org/en-US/docs/Web/API/WindowOrWorkerGlobalScope/fetch'">Check out the full list of available options here</a></p>
<p>Example usage:
This example demonstrates the usage of fetch to call an API and to get a list of git repositories.</p>
<pre><code class="lang-javascript"><span class="hljs-keyword">const</span> url = <span class="hljs-string">'https://api.github.com/users/shrutikapoor08/repos'</span>;

fetch(url)
  .then(<span class="hljs-function"><span class="hljs-params">response</span> =&gt;</span> response.json())
  .then(<span class="hljs-function"><span class="hljs-params">repos</span> =&gt;</span> {
    <span class="hljs-keyword">const</span> reposList = repos.map(<span class="hljs-function"><span class="hljs-params">repo</span> =&gt;</span> repo.name);
    <span class="hljs-built_in">console</span>.log(reposList);
  })
.catch(<span class="hljs-function"><span class="hljs-params">err</span> =&gt;</span> <span class="hljs-built_in">console</span>.log(err))
</code></pre>
<p>To send a POST request, here's how the method parameter can be used with async / await syntax.</p>
<pre><code class="lang-javascript"><span class="hljs-keyword">const</span> params = {
  <span class="hljs-attr">id</span>: <span class="hljs-number">123</span>
}

<span class="hljs-keyword">const</span> response = <span class="hljs-keyword">await</span> fetch(<span class="hljs-string">'url'</span>, {
  <span class="hljs-attr">method</span>: <span class="hljs-string">'POST'</span>,
  <span class="hljs-attr">headers</span>: {
    <span class="hljs-string">'Content-Type'</span>: <span class="hljs-string">'application/json'</span>
  },
  <span class="hljs-attr">body</span>: <span class="hljs-built_in">JSON</span>.stringify(params)
});

<span class="hljs-keyword">const</span> data = <span class="hljs-keyword">await</span> response.json();
</code></pre>
<hr>
<h3 id="heading-interested-in-more-jsbytes-sign-up-for-the-newsletterhttpstinylettercomshrutikapoor">Interested in more JSBytes? <a target="_blank" href="https://tinyletter.com/shrutikapoor"> Sign up for the newsletter</a></h3>
 ]]>
                </content:encoded>
            </item>
        
    </channel>
</rss>
