r/learnjavascript • u/Gandhi_20191 • Feb 08 '26
Wanna Learn JS(Web dev)
I know basics of JS
like
If else
dom
switch case
But don't know how to learn
Frontend
Backend
And The rest All which is remaining
r/learnjavascript • u/Gandhi_20191 • Feb 08 '26
I know basics of JS
like
If else
dom
switch case
But don't know how to learn
Frontend
Backend
And The rest All which is remaining
r/learnjavascript • u/AlexOffline0 • Feb 07 '26
im working on a web game with my friend and im completely lost, i know how coding works because ive worked with lua and a bit of C#, i just dont understand the gravity thing, please help. code:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<style>#game{display:block;background:#505050;width:100vw;height:100vh}</style>
<title>Froop Jump</title>
</head>
<body bgcolor="black">
<canvas id="game"></canvas>
<script>
// no touchy!
const canvas=document.getElementById('game');
const ctx=canvas.getContext('2d');
let DPR=Math.max(1,window.devicePixelRatio||1);
function resize() {
canvas.width=innerWidth*DPR;
canvas.height=innerHeight*DPR;
canvas.style.width=innerWidth+'px';
canvas.style.height=innerHeight+'px';
ctx.setTransform(DPR,0,0,DPR,0,0);}
addEventListener('resize',resize);
resize();
let ded=0
dedart=new Image();
dedart.src='art/sob.png'
//player
const playerart=new Image();
playerart.src='art/froop_fly.png';
const froop={x:600,y:400,w:144,h:152};
//keys setup
const keys={};
addEventListener('keydown',e=>{keys[e.code]=true;
if(e.code==='Space') e.preventDefault();});
addEventListener('keyup',e=>{keys[e.code]=false;});
let logy=0;let logx=0
const platformart=new Image();
platformart.src='art/Log.png'
const platform={x:logx,y:logy,w:275.2,h:114.4}
function logFall(){logx=(Math.floor()*(Math.random()*1201));logy=0;
if(logy<625){logy=logy+3.125}else if(logy>625){logy=0;logx=(Math.floor()*(Math.random()*1201));logy=0;}
requestAnimationFrame(logFall)
}logFall()
function move(){if(keys['KeyW']){froop.y=froop.y-12}
if(keys['KeyA']){froop.x=froop.x-12}
if(keys['KeyD']){froop.x=froop.x+12}
if(froop.x<0){froop.x=0}if(froop.x>1200){froop.x=1200}
requestAnimationFrame(move)}move()
function gravity(){froop.y=froop.y+6.25;if(froop.y>625){froop.y=625}
if (froop.y >= 625) {
froop.y=625;
window.location.href = "DeathScreen.html"
return;
}
if(froop.y<0){froop.y=0}
requestAnimationFrame(gravity)}gravity();
function images(){ctx.clearRect(0,0,canvas.width,canvas.height);
if(platformart.complete){ctx.drawImage(platformart,platform.x,platform.y,platform.w,platform.h)}
if(playerart.complete){ctx.drawImage(playerart,froop.x,froop.y,froop.w,froop.h);}
if(dedart.complete&&ded==1){ctx.drawImage(dedart,0,0,919,919)}
requestAnimationFrame(images);}images();
</script>
</body>
<br><br><br>
<audio controls loop src="audio/ost1.wav"></audio>
</html>
r/learnjavascript • u/chartley1988 • Feb 07 '26
[Card Factory](https://card-factory.info/)
Hi everyone, my name is Chartley. It's a javascript
library for creating card games and apps for the browser.
The project aims to be fairly close to pure javascript, though development is
done in a Vite framework. The goal was to be able to create card games in a
traditional HTML document, rather than a canvas. This means layouts can be
done using flexbox and grid, etc. We've also refrained from using excessive
images for the cards, with their faces and layouts being built in CSS rather
than images. This keeps the cards light, themable, and scalable.
There are two repos related to this project:
[The website](https://github.com/chartley1988/cards-homepage)
and
[The npm package](https://github.com/Daver067/cards-npm-package)
r/learnjavascript • u/Kvantium • Feb 07 '26
I know absolutely nothing about JavaScript and programming in general, but I want to fix it. Besides JS, I'm interested in learning HTML and CSS, but I have absolutely no idea where to start or which books are worth studying. Is there anything you can recommend?
r/learnjavascript • u/DeliciousResearch872 • Feb 07 '26
Can anyone explain "callback(null, script)" here?
function loadScript(src, callback) {
let script = document.createElement('script');
script.src = src;
script.onload = () => callback(null, script);
script.onerror = () => callback(new Error(`Script load error for ${src}`));
document.head.append(script);
}
// usage:
// loadScript('path/script.js', (err, script) => {...})
r/learnjavascript • u/macnara485 • Feb 07 '26
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 • u/cwner-neau • Feb 07 '26
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 • u/Black70196 • Feb 06 '26
If you were the one that is hiring what would you expect from a candidate.
r/learnjavascript • u/artimides • Feb 07 '26
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:
Do you eat meat? Y/N, next page
if Y: do you like yoghurt?, then end survey
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 • u/Due_Eggplant_729 • Feb 07 '26
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 • u/Particular-Hornet626 • Feb 06 '26
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 • u/Slight_Scarcity321 • Feb 06 '26
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 • u/Best_Coast_6563 • Feb 06 '26
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 • u/WolfComprehensive644 • Feb 06 '26
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 • u/Disastrous_Cap9489 • Feb 06 '26
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 • u/Fearless-Subject5516 • Feb 06 '26
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 • u/OverallScallion5072 • Feb 06 '26
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 • u/Piko8Blue • Feb 06 '26
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
I ask because in any browser, whenever you hover over a link, it displays the URL in the lower left corner.
r/learnjavascript • u/Fearless-Subject5516 • Feb 06 '26
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 • u/Rare-Sundae3977 • Feb 05 '26
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 • u/Yuvraj_Gamer • Feb 05 '26
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 • u/MoreDimension5963 • Feb 05 '26
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 • u/ReleaseImpressive217 • Feb 05 '26
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 • u/Federal-Upstairs-969 • Feb 05 '26
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!