r/learnjavascript • • Jan 24 '26

Simple Data Input Javascript program

0 Upvotes

I want to ask a user to input their first name, and the state were they live. Then send to a database. I am a NEWBIE. Help. Note: I did download node.js. I really don't know what I'm doing yet. Looks for a simple program to do this on my laptop. Any help appreciated.


r/learnjavascript • • Jan 24 '26

question about using ES6 classes.

1 Upvotes

pastebin

i was wondering, would this code be syntactically OK? i imagine there might be scenarios where you want all the functionality of the superclass method, but then you simply want to add more statements (more implementation) to it... could this work?


r/learnjavascript • • Jan 24 '26

Why can’t I see what’s in the multidimensional array?

1 Upvotes

This is my first time actually coding in javascript but I have experience in python and java. I am using Visual Studio Code and it is my first time using it.

I coded this very basic reduce function. The way I call this function results in a series of arrays. Everything other than the reduce function itself is provided to me by my teacher so I would perfer not to change it.

Here is the code:

const nums = [1,2,3,4,5];

const evensAndOdds = reduce(nums, (value, acc) => { if (value % 2 == 0) { acc.evens.push(value); } else { acc.odds.push(value); } return acc; }, {evens: [], odds: []});

console.log(evensAndOdds);

function reduce(data1, reducer, initialValue) { let reducedProduct = 0;

for (let element of data1) {
    let product = reducer(element, initialValue);
    reducedProduct += product;
}
return reducedProduct;

}

========================================================================== And here is the output:

0[object Object][object Object][object Object][object Object][object Object]

========================================================================= I want to be able to see the actual values. The example provided to me by my teacher says the result should be //{evens: [2,4], odds: [1,3,5]}; I understand my code could be wrong but I wont really know unless I can see the actual values.


r/learnjavascript • • Jan 24 '26

Made this directory of zero-build JS tools for simplicity

5 Upvotes

Hi r/learnjavascript  !

I'm working on this directory that compiles around 50 lightweight JS tools that requires absolutely no npm installs and no build steps, allowing for a streamlined dev experience, just a simple script tag and start coding! Would really like some feedback on my selection of the tools and engines or any tools you would like added to the website!

I thought these simple tools and setup processes would make it easier for beginner devs and everyone else alike to learn JS easier and experiment without needing to type in "npm install" ever again (i am being a bit overdramatic here with the repeated mentions of npm install, yes, but...)

Thank you all so much! :)

The website: https://vietnamesecoder.github.io/nobuild/


r/learnjavascript • • Jan 24 '26

I built a Full-Stack Auth Skeleton (Node/React/Postgres) that includes an Admin Panel and RBAC. Roast my architecture!

2 Upvotes

I realized that every time I start a new project, I waste days setting up the same boilerplate: Database, Auth, and most annoyingly a basic Admin Panel to manage users. Most tutorials stop at "Here is a JWT," but in the real world, we always need roles (Admin/User), session management, and a way to edit users without touching the raw DB.

So, I built templateAuthByPassphrase.

The Goal This is meant to be a "Clone & Go" template for freelance projects or internal tools. I need your feedback: specifically on the security implementation and the project structure. Is this "production-ready" enough for a mid-sized project?

Key Features (The "Adult" Stuff) I tried to avoid common tutorial pitfalls and focus on security and operations:

  • Session Management: Strictly HttpOnly cookies with in-memory storage (designed to be easily swapped for Redis). No access tokens in localStorage.
  • RBAC (Role-Based Access Control): Native support for USER vs ADMIN roles.

    • Includes a pre-built Admin Dashboard (React) to CRUD users.
  • Security hardening:

    • CSRF Protection: Double-submit cookie pattern.
    • Rate Limiting: Separate limits per IP and per Account to mitigate brute-force.
    • Audit Logs: A LoginAudit table tracks every success/failure with User-Agent and IP.
  • Dev vs Prod Docker Workflow:

    • Dev: Two containers (Vite hot-reload + API).
    • Prod: Single container build (API serves the static React bundle).

I’d appreciate any feedback about usabillity, security, or issues if you find a bug!
github.com/davy1ex/templateAuthByPassphrase


r/learnjavascript • • Jan 23 '26

Streams And Pipes/Pipelines: New Way VS Old Way?

1 Upvotes

There is a new way to stream things in NodeJS using async/await over the methods that NodeJS provided before async/await in NodeJS.

However I prefer the older way, it is less code, cleaner and easier to read.

Should I be using the newer way nevertheless?

Will the older way be deprecated in the future?

I know my code are examples of using http package when there are packages like Express. These are examples are just examples.

Older way with fs

import fs from 'fs';
import http from 'http';

const PORT = 8080;

http
	.createServer(async function (request, response) {
		if (request.url === '/') {
			response.setHeader('Content-Type', 'text/html');

			//Using older async way		
			fs.createReadStream('my-html.html').pipe(response);
		}

		else {
			response.writeHead(404, {
				'Content-Type': 'text/html',
			});

			response.end();
		}
	})
	.listen(PORT);

Newer way with fs/promises and stream/promises

import fs from 'fs/promises';
import { pipeline } from 'stream/promises';
import http from 'http';

const PORT = 8080;

http
	.createServer(async function (request, response) {
		if (request.url === '/') {
			response.setHeader('Content-Type', 'text/html');

			//Using newer async way
			const myReadableHandle = await fs.open('my-html.html');
			const myReadableStream = myReadableHandle.createReadStream();
			
			await pipeline(myReadableStream, response);
		}

		else {
			response.writeHead(404, {
				'Content-Type': 'text/html',
			});

			response.end();
		}
	})
	.listen(PORT);

r/learnjavascript • • Jan 23 '26

Why is JavaScript so hard to learn? Beginner projects don’t feel beginner

53 Upvotes

I am learning JavaScript and honestly feel like I am losing my mind. I have watched a lot of tutorials but even the ones labeled beginner skip fundamentals or explain things using jargon without really breaking concepts down. I can follow along but I do not truly understand what I am doing.

I can build simple things like a counter or a color flipper from scratch and those make sense. But I tried building a to-do app today and it feels insanely complicated. Everyone says it is a beginner project, yet every tutorial introduces a ton of concepts at once and I feel completely overwhelmed.

For context, I have a STEM degree and learned HTML and CSS pretty quickly. JavaScript, especially anything involving data or backend logic, feels abstract and confusing. People say just keep building, but the issue is understanding what I am building and why it works. Even when I ask AI tools to explain things simply, it still does not fully click.

For those who self taught JavaScript, how long did it take before you could build a simple CRUD app on your own and actually understand it? Is this frustration normal, am I missing something fundamental or maybe I just have a low IQ?


r/learnjavascript • • Jan 23 '26

Anyone got code for a scientific calculator like this? Hey, I want to try building a scientific calculator in JS/HTML/CSS. Seen a video showing one and it looks fun to make https://www.youtube.com/shorts/R6pGof6vVUY

0 Upvotes

Anyone got an example or tips to get started?


r/learnjavascript • • Jan 23 '26

Best way to learn JavaScript properly in the age of AI?

0 Upvotes

I recently completed a full-stack course, but I still struggle with JavaScript fundamentals.

I can follow tutorials, but when it comes to writing logic on my own, I get stuck.

With AI tools like ChatGPT and Copilot around, what’s the best way to *actually* learn JavaScript instead of just relying on AI?

Any advice, resources, or learning strategies would help.


r/learnjavascript • • Jan 23 '26

What is typical approach of lookup table based on 3 integers?

2 Upvotes

Hi, I am trying to figure out how to store a value that gets looked up based on 3 integers.

I have this:

var objexists = fast_lookup_table?.[int1]?.[int2]?.[int3];

if (objexists === undefined) {

fast_lookup_table[int1-1]=[];

fast_lookup_table[int1-1][int2-1]=[];

fast_lookup_table[int1-1][int2-1][int3-1] = [val1, val2];

}
At this point in code int1, int2, int3, val1, val2 are available. But logging shows me this is not populating the array.

Also, I understand there are probably better ways to do this, as I was just reading about lookup maps, but everything I am seeing shows these maps based on a single lookup key. If that is the best way, do I then simply create a string key such as 'int1:int2:int3'?

thanks


r/learnjavascript • • Jan 23 '26

1st yr, Self-taught learner requires feedback and guidance

5 Upvotes

Hey people, I'm 11 months into js and a few months into html and css.

I'm hoping I can ask you guys to have a look at this mini project I knocked up. It's nothing massive but Ive been trying to focus on things like event driven logic and turn based flow.
It's all in vanilla js and html as I wanted to learn to handle types and state before I step over to using tools like ts and react (dunno if it's the right choice)....

Anyway, this is my first upload to redit so I had to put this codebase on a separate repo for public view, by all means take it and have a use, theres a basic ui/ix for notes, levelling, shopping and battle. But mainly I'd love if you guys could look at how I structure code and name things.
I'm not at this for a job, in 47 😎 and just learning to pay back the 16 yr old me that never got to finish... Sappy shit? Yes, I hear that..

But please, be honest and have a look.

And thanks for all this.

Repo:-
https://github.com/Chefiroth/Noteish1.2-Public-Review

Blessings!


r/learnjavascript • • Jan 22 '26

Ways to learn JavaScript - Interviewees Wanted

0 Upvotes

Hi all!

I am building a new, free way of learning JavaScript.

I wanted to discuss with JavaScript newbies about their experience. I will pay $30 per 45 minute interview.

You can sign up here. https://calendly.com/josh-wolff-7/letschat


r/learnjavascript • • Jan 22 '26

Help with Objects

4 Upvotes

I don't get the purpose of value()

let dictionary = Object.create(null, {
  toString: { // define toString property
    value() { // the value is a function
      return Object.keys(this).join();
    }
  }
});

Why we can't make it work like this?

toString: {
      return Object.keys(this).join();
}

r/learnjavascript • • Jan 22 '26

How to check if archive format password protected / encrypted ?

1 Upvotes

Hello everyone, i have a task - i need to check if archive formats (eg. arj, zip, 7z, rar, tar, tgz) are password protected - encrypted. I have a React TS app.
My app allows users to work with files - upload, download, and edit them. And when someone upload encrypted archive i need to somehow save this info (maybe "isPasswordProtected" field or smth) and when other, different user click on this archive - i need to show in interface that archive is password protected (info bubble or smth)

BUT the main questions are:

  1. how do i check if archive is encrypted without unzipping it or just partly unzip it?
  2. Does provided archive formats has some kind of headers or smth like that? For example - if i want to check it on server - what exactly i need to check for?
  3. How to check it on client-side(frontend) ?

If u can, please, share some info or links or how file/archive should look like bc i think im a little lost right now


r/learnjavascript • • Jan 22 '26

Is it possible to check if a function with a specific parameter signature(?) exists?

0 Upvotes

Just curious - I know I can check if a specific function exists with

if (typeof myFunction !== "undefined") ...

Let's say myFunction could either be function myFunction() or function myFunction(parameter1), depending on which version of a library is loaded. typeof myFunction returns "function", is there a way to know if it's myFunction() or myFunction(parameter1)?

(Not sure if "parameter signature" is the right terminology)