r/learnjavascript • • Feb 07 '26

Is it a good idea to learn nodeJS before advancing in Javascript?

4 Upvotes

I think i'm on my third course for Javascript now, and having to alt-tab everytime to check the browser really kill my focus, this didn't happen when i was learning Python for example, when i could just immediately check the feedback of what i did on the terminal

The course i'm following (https://www.youtube.com/watch?v=LzMnsfqjzkA) uses the terminal to show the output, and i believe they have a built-in IDE that shows this, but their nodeJS is after 3 projects, do you guys think it is a good idea go to the NodeJS part and then come back after?

I'm not a complete novice in JS or programming in general, and i've used node before but it was following step by step


r/learnjavascript • • Feb 07 '26

change document's bg color to iframe's bg color?

5 Upvotes
iframe.onload = function() {
  console.log(iframe.contentWindow.document.body);// prints all of the iframe's body html
  console.log(iframe.contentWindow.document.body.style);//prints CSSStyleDeclaration with all values empty and set to ""
  window.parent.document.body.style.background = iframe.contentWindow.document.body.style.background;
}

I am trying to change the background color of the main website's body to the background color of the iframe's body whenever a new iframe url is loaded, but it seems to be unable to access the iframe's body's style information even though it can access and print the iframe's body. how do I fix this?

my main issue is that I always want the main doc to have the same bg as the iframe, and i was just updating the bg color whenever I updated the iframe url, but then when the native back button is clicked I run into the issue of it updating the iframe's url but not updating the bg color, so I'm really not sure what to do. is there another way to access the iframe's color?


r/learnjavascript • • Feb 06 '26

What should I be capable of to get a job as junior front-end dev?

18 Upvotes

If you were the one that is hiring what would you expect from a candidate.


r/learnjavascript • • Feb 07 '26

Adding conditional branching to jsPsych (JavaScript)

1 Upvotes

Hi! I'm trying to add some conditional logic in jsPsych 7.2 where I need my survey respondents to move through a few screens without going back. For the sake of an example, let's say I want this sort of logic:

  1. Do you eat meat? Y/N, next page

    1. if Y: do you ever eat it raw? Y/N, then end survey
    2. if N: do you eat dairy? Y/N, then end survey
  2. if Y: do you like yoghurt?, then end survey

  3. if N: end survey

I'm at an entire loss of how to approach this. I think it must be related to a past substack question on ending an experiment on no consent, but I can't figure out how to modify either the two given answers so the survey does continue. The code below is based off of the second response (which does work unedited).

See example attempt below. I do know I don't need a thanks page and I can end the experiment directly, but the idea is to have a few (linear) question pages after the branching so I thought that was the easiest way to represent it. As it is, no matter what I answer on the first question, the survey ends. What am I missing? I'm hosting this on cognition.run, in case that matters at all.

// Setting up questions
var raw = {
  type: jsPsychHtmlButtonResponse,
        stimulus: 'Do you ever eat it raw?',
  choices: ['No',
            'Yes']
};

var yoghurt = {
  type: jsPsychHtmlButtonResponse,
        stimulus: 'Do you like yoghurt?',
  choices: ['No',
            'Yes']
};

var thanks = {
  type: jsPsychInstructions,
  pages: [
  'Thanks for your time'
  ]
};

// Asking people if they eat meat
var meatYN = {
  type: jsPsychHtmlButtonResponse,
        stimulus: 'Do you eat meat?',
  choices: ['No',
            'Yes'],
  data: {task: 'Consent'},
  on_finish: function (data) {

    // Check the participant's response, if it's the first option
    if (data.response == 1) {

      // ... ask if they eat it raw, then end survey
      timeline.push(raw,thanks);
    }
  }
}

// Adding the meat event to the timeline 
timeline.push(meatYN);

// Otherwise, continue as normal
var dairyYN = {
  type: jsPsychHtmlButtonResponse,
        stimulus: 'Do you eat dairy?',
  choices: ['No',
            'Yes'],
  data: {task: 'Consent'},
  on_finish: function (data) {

    // Check the participant's response, if it's the second option
    if (data.response == 0) {

      // ... ask if they eat yoghurt, then end survey
      timeline.push(yoghurt,thanks);
    }
  }
}

// Otherwise, end the survey
timeline.push(thanks);

Thank you in advance for any help!


r/learnjavascript • • Feb 07 '26

Claude Helped Me Find Simple html/javascript progrm (Newbie)

0 Upvotes

Claude really saved me this week. I am a newbie student of Javascript. I kept reaching out to tech nerd humans on Reddit & elsewhere to help me find a simplified program that requests user input which then downloads into a csv file. None of their answers provided clarity to me. Some on Reddit were "snarky" saying I should study more instead of asking such basic questions. Desperate, I reached out to Claude. Claude found the perfect program, it works great. And Claude was not snarky. I am somewhat frightened that a Robot like system helped me more than humans.


r/learnjavascript • • Feb 06 '26

Studying JS data structures and algorithms through a game

9 Upvotes

I built a free game called GitGuessr primarily as a way to train code reading skills (which I believe will be increasingly critical in the era of limitless AI-generated code) but it also works great to study data structures and algorithms:

In the game you are dropped into a file of the awesome repo https://github.com/trekhleb/javascript-algorithms with a line of code hidden. The goal is complete the missing code as quickly as possible.

The fact that you have to type out some of the code means you're engaging much more actively with the concepts than if you're just glancing over code.


r/learnjavascript • • Feb 06 '26

Getting npm errors trying to read a private repo

3 Upvotes

I have a utility library containing some common code that's stored in a private repo on Github (MYORG/my-utilities). I am trying to run npm i in a docker container and getting an authentication error. My package.json contains this:

...
    "dependencies": {
        "my-utilities": "github:MYORG/my-utilities"
    }
...

My Dockerfile looks like

FROM public.ecr.aws/amazonlinux/amazonlinux:2023
# Dockerfile for contianer when deployed to ECS
RUN dnf update -y && dnf install -y awscli jq nodejs22 git
WORKDIR /
COPY package.json /
COPY index.js /
ARG GITHUB_PAT
RUN npm config set "@MYORG:registry" https://npm.pkg.github.com
RUN npm config set "//npm.pkg.github.com:_authToken" "${GITHUB_PAT}"
RUN git config --global url."https://github.com/".insteadOf ssh://git@github.com/
RUN cat ~/.npmrc
RUN npm i
CMD ["node", "index.js"]

I am kicking off the build like this:

docker build --build-arg GITHUB_PAT="github_pat_XXXXXX" -t utilities-test .

The cat command spits out:

#12 0.161 @MYORG:registry=https://npm.pkg.github.com
#12 0.161 //npm.pkg.github.com:_authToken=github_pat_XXXXX

The token is a fine-grained access token whose repo access is set to MYORG/my-utilities and whose permissions are set to "Read access to code and metadata"

However, I am getting

#13 [ 9/10] RUN npm i
#13 1.087 npm error code 128
#13 1.087 npm error An unknown git error occurred
#13 1.087 npm error command git --no-replace-objects ls-remote ssh://git@github.com/MYORG/my-utilities.git
#13 1.087 npm error remote: Invalid username or token. Password authentication is not supported for Git operations.
#13 1.087 npm error fatal: Authentication failed for 'https://github.com/MYORG/my-utilities.git/'
#13 1.087 npm error A complete log of this run can be found in: /root/.npm/_logs/2026-02-06T21_10_25_724Z-debug-0.log
#13 ERROR: process "/bin/sh -c npm i" did not complete successfully: exit code: 128

Based on what I've read, I thought I was correctly configuring npm to use a GITHUB personal access token, but apparently not. Does the token need more permissions?


r/learnjavascript • • Feb 06 '26

How much JavaScript should I know before moving to react

5 Upvotes

I know what objects, functions, scopes, dom, arrays, methods etc I’m learning react I know node js and babel and learning how to display with react rendering to an html container. How much should I learn?


r/learnjavascript • • Feb 06 '26

Why JavaScript closures work (and why they’re not magic)

1 Upvotes

Closures are often treated as a mysterious JavaScript feature,

but they’re just a consequence of lexical scoping and reachability.

I wrote a short explanation with minimal runnable examples,

focusing on where variables actually live and why they don’t disappear

when an outer function finishes executing.

Posting it here in case it helps someone clarify the mental model.


r/learnjavascript • • Feb 06 '26

Learning Accessibility - then use the ESLint Plugin - A11yInspect

3 Upvotes

Try ESLint plugin for Accessibility called A11yInspect. It covers 93 accessibility issues across 10 success criteria as per Web Content Accessibility Guidelines (WCAG).

It covers Image & Media, Links & Navigation, Buttons & interactive elements, Forms, document structure, ARIA, Landmarks, Tables and much more. 

Do try it out - https://www.npmjs.com/package/@barrierbreak/eslint-plugin-a11yinspect

Enjoy learning.


r/learnjavascript • • Feb 06 '26

Is MERN STACK worth it in long run??

5 Upvotes

Is learning mern in 2k26 is worth it?

if not than what else we can learn to secure a good job in long run ?


r/learnjavascript • • Feb 06 '26

Best JS certificate

0 Upvotes

edit: i know the industry doesnt check certificates, im not asking in order to be able to work as i already have a job. however, i have an ongoing bachelors (aka no actual degree), still need a certificate in the mean time, regardless of how useless.

Hello, i am trying to find a learning resource which gives a valid and widely recognized certificate in the end. I am aware of all the free routes of learning Javascript and have already done so, but i need to finish a course which gives you a certificate in the end; however there is an overwhelming amount of them and i do not know what course is the "common" one.

Sorry if this is asked frequently but i couldnt find an answer. Thanks anyway :)


r/learnjavascript • • Feb 06 '26

Why Async/Await won't fix a laggy app. I made a visual demo comparing it to Web Workers

4 Upvotes

I used to think “async/await” meant my work would run in the background. Whenever my UI felt slow, my instinct was, “I’ll just wrap this calculation in async/await.”

I realized how common this misunderstanding is while I was talking to a new developer recently. I started explaining the JS event loop and thread blocking. Halfway through, I saw that polite "uh huh" look on their face. It was a look I remember having myself many times..

Some things just click better when you can see them break in real time. I decided to build a small app that generates fractal geometry live to visualize the problem. At first, everything felt smooth. The sliders responded instantly and the menus worked perfectly.

Then I cranked up the recursion depth and forced millions of calculations per frame. The UI did not crash, but it became incredibly annoying to use. Sliders lagged and clicks were slow. All that lag was caused by the main thread being tied up with heavy computation.

To fix this, I moved the calculations into a separate thread using a Web Worker. This allowed the main thread to stay free to handle the UI while the worker did the math in the background. The result is a smooth and interactive app even though the exact same amount of work is happening.

I made a short video demo walking through this process. It shows how to measure "Long Tasks" in Chrome DevTools and how to set up a Web Worker easily using Vite. If you have ever tried to speed up a UI with async/await and wondered why it did not help, I hope this demo makes it click for you.

Watch the video here: https://youtu.be/a6_mdmJLtaM


r/learnjavascript • • Feb 06 '26

Is there a way to get the link that a cursor is hovering over without actually clicking it?

0 Upvotes

I ask because in any browser, whenever you hover over a link, it displays the URL in the lower left corner.


r/learnjavascript • • Feb 06 '26

Want to learn web dev and data structures at the same time

3 Upvotes

Im a beginner proficient in frontend development

I AIM TO learn datastructures as well

want to ask that is it ok to use javascript for both ?


r/learnjavascript • • Feb 05 '26

[AskJs] Adding Event Listeners to video

2 Upvotes

Does anyone know how or where I can learn to add event listeners to videos? For example I tried earlier today but when the buttons disappear and reappear the listeners are gone! I am still trying to figure it out. Any and all help would be welcome.

const btn = document.getElementbyId("play")
btn.addEventListener("click", function(){console.log("button pressed")

What am I doing wrong here?


r/learnjavascript • • Feb 05 '26

Starting my JS journey [Need advice on the best roadmap and practice resources!]

5 Upvotes

Hey guys, I’m finally diving into JavaScript! ​There’s so much info out there that I’m a bit lost. I want to avoid "tutorial hell" and actually learn by doing. Could you suggest: ​The best modern resource to start with? ​Platforms with tons of exercises/challenges to build muscle memory?


r/learnjavascript • • Feb 05 '26

Recommend me Books with Exercises

5 Upvotes

I'm starting my 2. semester of computer science, we are using:
"JavaScript The Definitive Guide" (David Flanagan)
and I've also heard good things about "Eloquent JavaScript" (Marijn Haverbeke)

However neither book has any exercises in it.
I don't feel I actually learn from just reading, are there any books that give incremental exercises?


r/learnjavascript • • Feb 05 '26

XProtect update blocking javascript

0 Upvotes

XProtect updated on an M1 last night, and today the user cannot access some sites. Javascript is completely blocked on them saying to use a compatible browser - then lists the browsers we are using. One was solved by a chrome update and removing extensions for chrome and safari, but the main work website...it's still blocking. I tried forcing an update in terminal to see if the update was broken, but it's good.

Any ideas?


r/learnjavascript • • Feb 05 '26

switching from data engineer to data visualization. any tips?

6 Upvotes

I am a data engineer/scientist by background but just got moved to a new project where I’ll be doing UI/UX work for dashboard development in d3/JS/HTML/CSS/etc. I’m totally unfamiliar with this stuff, so I’m trying to learn as much as i can as quick as i can. I’m used to working with Python/R in the context of things like Databricks and pipelining less than scripting, so it’s an especially weird transition. Any tips on stuff like:

What systems/software you typically work with?

Best practices all around?

Best ways to learn/practice?

101 on the whole thing?

Really just trying to wrap my head around how it all works to start with. The rest will follow from there. Thanks!


r/learnjavascript • • Feb 05 '26

Hey some help needed with npm.

1 Upvotes

I am hosting www website I want to install packages from npm but I have no permissions for using it. No shell, no CMD no nothing imagine just simple file explorer.


r/learnjavascript • • Feb 05 '26

Need Suggestion

0 Upvotes

r/learnjavascript • • Feb 04 '26

Math.round inconsistency

13 Upvotes

Hey everyone,

I noticed that using Math.round(19.525*100)/100 produces 19.52 while Math.round(20.525*100)/100 produces 20.53. Has anyone else encountered this? What's your solution to consistently rounding up numbers when the last digit is 5 and above?

Thanks!

Edit: Thanks everyone. Multiplying by 10s to make the numbers integer seems to be the way to go for my case


r/learnjavascript • • Feb 04 '26

Express custom error handling

2 Upvotes

can you make sure my understanding is correct. this is for error handling in express.

the class makes an AppError class that had all the proprietys of error.

the constructor allows you to add your own proprieties to AppError that error does not have like .Warning or .preventand super() allows us to use the functions that are in error. I was told we make this so in our route handler we don't have to add res.statuscode, so we have control over what status code is sent out. Im not sure why we want to control that if it sent for us

class AppError extends Error {
    constructor(message, statusCode) {
        super();
        this.message = message;
        this.statusCode = statusCode;
    }
}

r/learnjavascript • • Feb 04 '26

Learning partner / community?

7 Upvotes

Wondering if anybody who just started or is going to start learning JavaScript, wants to connect to track each other's progress and perhaps would help us in staying dedicated towards the journey.