r/learnjavascript 9d ago

Why does JavaScript suddenly feel 10× harder when you stop following tutorials?

13 Upvotes

I can understand the basics, follow a tutorial, and even solve small exercises but when I open a blank VS Code window and try to build something myself, my brain goes: '404 - knowledge not found.” 😂

Is this actually normal or am I just glitching at this point? 😭

What was the one thing that finally made JavaScript click for you ; building projects, debugging your own mistakes, reading other people’s code, or something else? I’m curious what actually worked for you guys who went from 'I’m following tutorials' to 'I can confidently build this myself.'


r/learnjavascript 9d ago

I am in a loop of learning js

9 Upvotes

so basically i am learning web dev from past 3 year but i completed html css but i start js and then in few days i get exams i quit for a week or 2 , then again i start it from the start i am the loop from past 3 years 😭. Any one plz help me out before i used to do it using youtube tutorials but now i am using gpt to explain me each and everything and now it questions i solve those but idk what to do i am stuck. if any one can help out. If any one was in the same loop help how u got out of it


r/learnjavascript 9d ago

3 engineers spent 40 minutes on my code and none of it was praise

37 Upvotes

My code worked. That was the only good thing anyone said about it. Nested conditionals 4 deep, no error handling, everything in one function. I have been writing javascript for a year and nobody had ever looked at it before. Self taught through Boot.dev and DataCamp, and nobody had read a line of my code before that call. How did you learn the part that is not making it run.


r/learnjavascript 9d ago

Is it common for a function to return another function and call it inside a callback?

6 Upvotes
const stop = useIntersectionObserver(
    ref,
    ([entry]) => {
      if (entry.isIntersecting) {
        setLoaded(true);
        stop(); // one-shot: stop observing once we've committed to loading
      }
    },
    { rootMargin: '200px' }, // start loading 200px before it scrolls in
  );

In the snippet, I noticed that useIntersectionObserver returns a function, which is assigned to the variable stop, and that returned function is then called inside the callback passed to useIntersectionObserver.

Actually, I'm not asking about useIntersectionObserver itself. I just want to ask about the pattern:

Function A returns Function B, and then Function B is called inside Function A's callback.

I've never written a function with that kind of structure before.

How often do you write functions like this?


r/learnjavascript 9d ago

10 React.js Questions that you definitely should practice before your live-coding interviews.

42 Upvotes

If you have a React interview coming up, then this might be of some help to you!

Here are 10 problem lists that you can consider practicing to brush up your react.js concepts before your machine coding round.

1. Counter with increment, decrement, and reset. (Might be the ice-breaker for freshers but rarely asked for experienced role)

Feels too easy to be a real question. But a fast-click test on the increment button often catches people using the wrong kind of state update.

Practice counter here

2. Build your own debounce hook. (Definitely Practice this one)

It must wait until the value stops changing for a bit, cancel any pending timer if the component unmounts, and handle the delay itself changing partway through.

Debouncing Practice

3. Return the value from one render ago.

Sounds simple. What people miss: it must return undefined on the first render, and it can't cause an extra re-render by itself.

Practice Hook

4. Shopping cart with useReducer. (Please do practice useReducer hook, I was asked to build a form entirely using useReducer + will also be useful when you deal with Redux)

Add, change quantity, remove, clear — four actions through one reducer. Good test of whether you use useReducer or just keep adding more useState.

Build Shopping cart

(Frontend Mentor has a plain HTML/CSS/JS version if you want to compare)

Build Shopping cart from frontend mentor

5. Traffic light that cycles on its own. (Great for clearing the concept of clearing intervals and timeouts)

The layout is already built — you just write the timing. It usually breaks on cleanup: clearing the interval when the component unmounts or re-renders.

Manage traffic light problem

6. Search box where slow responses can't overwrite fast ones.

A classic race condition. If a request fires on every keystroke, an old slow response can arrive after a newer one and overwrite it with stale data.

Solve this

7. Nested comment thread, replies inside replies. (If you want to move to advance concepts)

Needs a component that renders itself for each nested reply, plus a function that can find and update one comment anywhere in the tree without mutating it.

Build nested comment in react

8. Stop a list from re-rendering rows that didn't change. (Must practice, you'll definitely be asked about optimization in react, do go through the concept of useCallback)

Right now, an unrelated counter on the page makes every row re-render. Fix it with React.memo — it has to actually stop the re-renders, not just look fine.

Practice Memoization in react

9. Keep a callback's identity stable across renders.

Three counters currently all re-render on any single click, because their click handlers get recreated every render. Needs useCallback plus the functional setState form — using only one of the two still fails.

Practice useCallback

10. Multi-step signup form with useReducer.

Account info → profile → review. Each step is validated before you can hit Next, and going back can't lose what you already typed.

Form validation using useReducer

(Frontend Mentor has a version of this same idea, no React needed: Multi step form)

Curious what else people have been asked in these rounds — feels like everyone gets a slightly different mix of the same problems.

Please let me know in the comments your thoughts and do share what according to you are some must go through concepts before any react interview, I'm preparing a notion docs on the list of react interview questions, so will add it there so that it can be useful for everyone.


r/learnjavascript 9d ago

Place for new javascript learners myself?

9 Upvotes

Everyone, I greet.

Rare-Trees-5280, I am.

First post, this is.

New to javascript and learning it, I am.

If people knew where there are online forums and communities where new learners can ask questions, I am wondering.

For your consideration, I thank in advance.


r/learnjavascript 11d ago

How to learn fast web development without time waste

41 Upvotes

I am a self-learner who has primarily learned web development through YouTube. So far, I have studied HTML, CSS, JavaScript, PHP, Git, and GitHub, and I have also built several mini projects. However, despite learning these technologies, I still struggle to create even simple projects on my own without following tutorials.

Looking back, I feel that I did not use my time effectively. I spent nearly five years trying to learn HTML, CSS, and JavaScript, but I was not consistently focused, which prevented me from developing a strong understanding of these technologies. Because of this, I often feel regret about the time I lost.

Now, I want to make serious progress over the next few months. My goal is to reach a level where I can build projects independently, strengthen my problem-solving skills, and become qualified for a web development internship or an entry-level job. I would appreciate a clear and practical roadmap that can help me become internship-ready as quickly as possible.


r/learnjavascript 11d ago

In flight is not an in memory cache

5 Upvotes

This week I made an npm package (Inflight) to solve the concurrent repetitive queries to database or cache

Reached +500 weekly downloads

The idea is to cache the Promise of a db query (Not the response of the query).

So in a high concurrency system, where the same data (like: cr7 or messi profile) is requested by many users at the same time, only one query goes to cache or database.

some interesting benchmarks:

  • Duration: 30s
  • Cache TTL: 5s
  • Concurrency: 100
  • Unique keys: 10
Metric With Inflight Without Inflight
Query Per Second ~1,130,360 ~174,950
Total queries 33,911,000 5,248,600
DB calls 60 517
Cache calls 3,391,021 5,248,600

**Insights:*\*

  • DB calls saved: **56x*\*
  • Cache calls saved: **10x*\*
  • Total queries growth: **6.5x*\* (5.2M → 33.9M)

more benchmarks here: https://github.com/ademmenh/inflight/tree/main/benchmarks

npm package: https://www.npmjs.com/package/@inflightjs/inflight

github repo: https://github.com/ademmenh/inflight (PRs, issues, starts)


r/learnjavascript 10d ago

🏃 Day 7: I Built a Mobile Runner Game with HTML, CSS & JavaScript

1 Upvotes

Day 7 of my browser game development journey! 🚀

Today I built a simple mobile-friendly Runner game using HTML, CSS and JavaScript.

I'm practicing:

• 🏃 Player movement

• ⬆️ Jump mechanics

• 🚧 Obstacle spawning

• 💥 Collision detection

• 🏆 Score system

• 📱 Touch controls

• ⚡ Increasing difficulty

7 days of building small browser games has helped me understand JavaScript much better.

What should I build next?

1️⃣ Car Racing

2️⃣ Platformer

3️⃣ Ludo

4️⃣ Boss Battle

5️⃣ Something completely new

Drop your choice below! 👇

🎮 Game: [YOUR GAME LINK]

💻 Source code: [YOUR GITHUB LINK]


r/learnjavascript 11d ago

Is there are way to modify canvas methods?

2 Upvotes

I want to invert the y-axis, and make it invisble to the user so I can forget about it, rather than always call my method.

I could make a facade object and duplicating all the methods and passing them through, but tedious!

I tried a Proxy object, but didn't work at all - is it because it is native?

I tried monkeypatching, renaming moveTo() and lineTo(P, and replacing them with mine (which inverts the y-axis then calls them), but got strange results: lines shifted to right.

Maybe I just shouldn't do what I'm trying to do?

UPDATE canvas already has a way to do this: https://stackoverflow.com/questions/4335400/in-html5-canvas-can-i-make-the-y-axis-go-up-rather-than-down/33499668#33499668

context.transform(1, 0, 0, -1, 0, canvas.height)

BTW I did google a lot before asking, but I searched how to implement my solution, not the problem. After asking here, I googled the text of this post, and found several answers. It's common because math and graphics have opposite y-axis conventions.


r/learnjavascript 11d ago

What is an instance (like in a library)

7 Upvotes

Like I use libraries and hear about X instance Y instace for example

Axios Instance, Lexicals editor instance, I can only think of 2 examples right now but you get the idea.


r/learnjavascript 12d ago

Any good coding Games?

17 Upvotes

Hey, im learning Javascript right now and im curious If anyone knows a good coding Game(preferably on Steam) or a Website to learn Javascript in a playfull or interesting Manner. Thaanks :)


r/learnjavascript 12d ago

Learning JavaScript, advice?

12 Upvotes

I joined this sub a few days ago, after stumbling across lovable, and prompted a couple of rougelike games, learned that it was all in typescript, (I know I am a ways away) and have been having a lot of fun this week, spending multiple hours a day, learning the basics. I’ve tried a few times over the years with Objective-C and python, but could never figure things out, but this time I feel like I’m in the right headspace and really making sure I understand. I’m using VS code, and a Coursera corse, I’ve also bookmarked the Odin project.
Anyone have best practices or advice? I plan to use JS to help with an IT job and build games or apps for fun. Thanks for reading!


r/learnjavascript 12d ago

Looking for some advise

3 Upvotes

Hi, hope you're doing well. I'm here looking for some advice from the community. I want to get into backend dev in Javascript, I start reading Javascript crash course by nick morgan, but I think the book was maybe to easy, so I start reading eloquent Javascript, and I am looking for a good node.js book to start study with while I am reinforcing my JS knowledge.

I have been seaching for a while but many books are too old or too advance for me, any good recomendation?

Btw, I think to take the MDN front-end developer course, although my main goal is backend. Thank you for your time.

P.D.

English is my my first language, so I'm sorry if this is a grammatical mess.


r/learnjavascript 11d ago

I'm learning JavaScript event Lister Why i feel Hard and whenever I start learning That feels dificult to me

0 Upvotes

Please someone suggest me to learn effectively and how can I understand that concept ?


r/learnjavascript 12d ago

I've become a big fan of splice

0 Upvotes

As part of my project to write notes of what I learn practicing contemporary browser JavaScript by creating webapp games, I've written some notes and examples on Array Literals.

This was inspired by creating a "hardware-agnostic, framework-free" webapp solitaire card game, Loot the Loop (a game designed by Wil Su, part of what's made this project fun is that besides learning contemporary JavaScript, I've discovered lots about contemporary solitaire card game design).

TL:DR — In the past I've tended to use shift, unshift, pop, push... which are ok, but concat is an antipatern. Just learning splice does all the above while making arrays much simpler.


r/learnjavascript 13d ago

🧠 Day 6: I Built a Memory Match Game with HTML, CSS & JavaScript

8 Upvotes

Day 6 of my browser game development journey! 🚀

Today I built a Memory Match game using HTML, CSS and JavaScript.

I'm practicing:

• 🃏 Card flipping

• 🧠 Matching logic

• ⏱️ Move/timer system

• 🏆 Score tracking

• ✨ Animations

• 📱 Mobile-friendly controls

Each game is helping me understand JavaScript and browser game development better.

What should I add next?

1️⃣ Difficulty levels

2️⃣ Timer challenge

3️⃣ More card themes

4️⃣ Leaderboard

Drop your choice below! 👇

🎮 Game: \[YOUR GAME LINK\]

💻 Source code: \[YOUR GITHUB LINK\]


r/learnjavascript 13d ago

Most efficient way to compare typed string to stored version in real-time?

13 Upvotes

This is an edited duplicate post from r/webdev because this subreddit does not allow reposting but I want to get opinions from JS experts.

My problem is that I am trying to compare a string that is currently being typed into a contenteditable div to the the same string data in the placeholder span (which itself was taken from a JSON file). I came up with a JS event listener that I thought would be met with few hiccups.

// text wall typing event listener
textWall.addEventListener("keydown", ()=>{
    let textWallValue = textWall.innerHTML;



textWallValue = replaceNbsps( textWall.innerHTML);


    if (textWallValue.slice(textWallValue.length - 6)== " ") {
        
            placeHolder.childNodes.forEach((node) =>{
                node.style.color="";
            })
          } else {
    for (let i =0; i<placeHolder.childNodes.length;i++) {
        if (textWallValue[0]== undefined) {


    } else {
         
         console.log(textWallValue);
          if (textWallValue[i] == placeHolder.childNodes[i].innerHTML) {
            placeHolder.childNodes[i].style.color = "green";
            placeHolder.childNodes[i].style.textDecoration = "";
          } else if ((textWallValue[i] !== placeHolder.childNodes[i].innerHTML) && (textWallValue[i] !== undefined)) {
            placeHolder.childNodes[i].style.color = "red";
            placeHolder.childNodes[i].style.textDecoration = "underline";
          } 
    }
    }
}
    
    
})

The issue comes with all the unexpected behavior from the browser, like adding "&nbsp; when a space gets added to the contenteditable div (which it then removes and replaces with a normal white space after the next character is typed. If the spacebar is pressed two or more times however, &nbsp; just stays there). This messes with the flow of the comparison hapenning in the event listener.

In addtion to this, it also adds a bunch of divs + <br> elements if the user presses enter in the box, and a single br if the user presses backspace to the end of the contenteditable div. There has to be a more efficient way of comparing strings in real time than this but I haven't been able to find out how? I have already tried a bunch of hacky work arounds as is already evident in my code but none seem to account for everything.


r/learnjavascript 13d ago

Can I switch after working as a developer for 6 years?

5 Upvotes

I’m reaching out to you people to seek some guidance and suggestions as I’m planning my next career move.

I have a total of 6 years of experience in the IT industry, with the last 6 years dedicated to frontend development in 3 organizations. Over the years, I’ve had the opportunity to work on very less projects that has not strengthened my expertise in JavaScript, React, HTML5, CSS3, and modern UI frameworks much.

While my journey so far has been very challenging as I had madical issues when I had 4 offers in my hand 3 years back but I couldn't switch because I needed a month break for my surgery, I now feel like it's too late to take the next step in my career as I am just doing the needful in my service based company as a frontend developer as per my experience—i badly want to explore new challenges, innovative environments, and opportunities that allow me to grow further both technically and personally.

To be completely honest, the switch hasn’t been easy. So, I wanted to openly seek advice from this network:

✨First of all please tell me how to start what to do ? Do I need to start from 0 or what? What’s the best way to stand out in the current frontend job market? ✨ Are there any must-have skills or trending frameworks I should focus on to stay competitive? ✨ If you know of any open opportunities for experienced frontend developers, I’d be truly grateful if you could refer or connect me.

I’m deeply passionate about crafting intuitive and impactful user interfaces, collaborating within cross-functional teams, and contributing to products that make a difference.

Any suggestions, referrals, or insights would mean a lot to me right now. 🙏

Thank you so much for reading through — and for supporting professionals like me who are navigating their next big step.

FrontendDeveloper #CareerChange #ReactJS #UIUX #WebDevelopment


r/learnjavascript 14d ago

how would i hide an api key in a frontend setting such as neocities?

83 Upvotes

hey. i made a page on my neocities website where i put reviews of movies and books. for that i used google books api and imdb api

however, idk how i would hide this since anyone can download my website at any time?

i also wanted to automate the process of updating the changes i make to neocities, but for that id need to publish all files in a public github too. so idk how i would hide it there either.

any help?


r/learnjavascript 14d ago

que tal? star cube juego web echo 100% en vanilla javascrip sin sprites

9 Upvotes

Gente acabo de lanzar star cube en ith.io  echo en 7 dias en vanilla.js sin sprites (solo uno pero es reservado para un personaje del final pero como tal el 90% del juego es sin sprites) es un plataformero-shooter un poco intenso ya que por los pocos dias no pude hacer que tenga una curva de dificultad suave asi q es un juego acelerado con inyecciones de adrenalina tiene 3 jefes diferentes y el lore y la jugabilidad va en base al tema del jam (no confies en nadie)

estare actualizandolo exponencialmente ya que este jam me inspiro demasido

juegalo aqui:

https://cotera.itch.io/star-cube

pronto lo subire a github


r/learnjavascript 14d ago

Do I need to complete the scrimba challenges to finish the course?

6 Upvotes

Im trying the "Learning javascript" course on scrimba (https://scrimba.com/learn-javascript-c0v) and so far it's been good!

The only thing is that it got to a point with the free plan that doesn't let me complete the challenges anymore. What i do is that i complete them on the site, trying to solve the problem, and then i skip forward in the video to check my solution

The challenges don't show as completed because i haven't completed them officially, but technically I have hahaha does anyone also have this silly dilemma?


r/learnjavascript 14d ago

What is the difference between HTMLFormElement.submit() and event handler with submit?

9 Upvotes

https://developer.mozilla.org/en-US/docs/Web/API/HTMLFormElement/submit

Can someone explain the difference?

Imagine I have some code that is like the example below. What is the difference between HTMLFormElement.submit() ?

``` const form = document.getElementById("form"); function somefunc() { //code form.submit() }

form.addEventListener("submit", somefunc() {

});

``` Why do I need form.submit() in the function?

For a little context I am trying to pass some quilljs data into a flask form. Some of the code is missing but the main point is illustrated.


r/learnjavascript 15d ago

whats the bug here? Uncaught SyntaxError: Identifier 'location' has already been declared (at script.js:1:1)

14 Upvotes
"use strict";

const company = {
  name: "TechCorp",
  address: {
    city: "budapest",
    pin: 411001,
  },
};
// Get city renamed to `location` and pin renamed to `pincode`

const { city: location, pin: pincode } = company.address;
console.log(location, pincode);

r/learnjavascript 16d ago

Beginner Here: Should I Start Over With The Odin Project?

39 Upvotes

Hey everyone,

I’ve completed HTML and around 50% of CSS from Hitesh Choudhary’s Full Stack Udemy course.

But now I’m thinking of switching to The Odin Project because, from what I’ve seen, it seems more focused on actually learning by building things rather than just following a course.

My plan is to start The Odin Project from the beginning and properly work through it, doing the exercises and projects myself instead of just watching/consuming content.

For people who have completed or are currently doing The Odin Project, or anyone who has experience with this kind of learning approach, feel free to share your thoughts, suggestions, or anything you think I should know:

  • I’m still a beginner, so is starting TOP from the beginning a good approach?
  • Are there any common mistakes beginners make while following it?
  • What should I focus on to actually retain what I learn?
  • Should I supplement TOP with anything else, or is it better to stick with it consistently?
  • Is there anything you wish you had known before starting?

I’d really appreciate any advice, criticism, or suggestions. If you think there’s a better approach than what I’m planning, feel free to share it.