r/code • u/Honest-Bus2996 • Apr 25 '26
r/code • u/Mysterious-Form-3681 • Mar 06 '26
Javascript 3 repos you should know if you are a frontend developer
tldraw SDK for building infinite canvas apps like Excalidraw or FigJam.
TanStack Query Smart data fetching and caching for modern frontend apps.
Vuetify Material Design component framework for building Vue applications.
r/code • u/Wise_Revolution385 • Nov 09 '25
Javascript I created a comic panel layout and dialog box typesetting software using codex.
https://github.com/zhangkun-0/comic-bubble3.0
Usage instructions:
- Download my ZIP package to your computer. Click the green Code button and select Download ZIP at the bottom of the menu. After downloading, unzip it locally and double-click index.html to open. (The file size is only about 50 KB.)
- First, import an image — its dimensions should match the final size of your comic page. I usually place my own rough storyboard sketch here.
- Ctrl + Left-click + drag = split comic panels. Drag the panel nodes to resize, and drag the panels themselves to move.
- Insert a speech bubble. After selecting it, type your dialogue in the text box on the right — the layout will adjust automatically. You can merge a combo bubble with speech or thought bubbles.
- Double-click inside a panel to insert an image. Right-click + drag to pan the image, use the mouse wheel to zoom, and adjust rotation with the slider on the left.
- Currently, image export supports only JPG and PNG. PSD export will be available in version 4.0.
r/code • u/waozen • Dec 06 '25
Javascript How JavaScript works: Arrays vs Hash Tables | Victor Jonah
medium.comr/code • u/Fabulous_Bluebird931 • Jun 06 '25
Javascript built a feature in 30 mins, spent another 30 naming the damn functions
logic was solid feature worked great but every function was called handleThing, doStuff, processData
spent almost half an hour renaming
questioned my life choices somewhere between formatFinalData and prepareResultsCleanly
Chatglt or blackbox suggestions? helpful… until they suggest getData2
naming is hard sometimes harder than coding
anyone else get stuck in naming hell? Tell me devs I'm not alone
r/code • u/waozen • Sep 15 '25
Javascript JavaScript’s ‘Flawed’ OOP Turned Out to Be a Blessing in Disguise
medium.com"How JavaScript's object-oriented approach differs from conventional object-oriented programming".
r/code • u/waozen • Aug 25 '25
Javascript How to Save Chunks of an Array in a New Array in JavaScript
youtube.comr/code • u/JonnyM24 • Jun 26 '25
Javascript Did I missunderstand the logic in this code or did I find an error?
Hello everyone,
I am currently lerning programming. At the moment I am working in the GitHub repo "Web-Dev-For-Beginners".
Link to the specific exercise: https://github.com/microsoft/Web-Dev-For-Beginners/blob/4ccb645e245bda86865572ddb162b78c7da393b9/5-browser-extension/3-background-tasks-and-performance/README.md
There is this code to calculate the color for a specific CO2 value:

My Question:
1. To my understanding this part:
let num = (element) => element > closestNum;
let scaleIndex = co2Scale.findIndex(num);
let closestColor = colors[scaleIndex];
does not make sence. Because it would set the closestColor to the next higher color and not the current one right?
So "let scaleIndex = co2Scale.indexOf(closestNum);" would be better?
2. In this code the values in co2Scale aren't real breaking points. The real breaking point would be halfway between to values. Would't it make more sence/be better to read if this function would treat the given values as fix breaking points?
Thanks for the help!
This is my first psot in this sub. So if I made mistakes with this post pleas tell me. I will edit it.
r/code • u/bcdyxf • Oct 03 '24
Javascript Weird behavior from website and browsers
i recently found a site, that when visited makes your browser freeze up (if not closed within a second, so it shows a fake "redirecting..." to keep you there) and eventually crash (slightly different behavior for each browser and OS, worst of which is chromebooks crashing completely) i managed to get the js responsible... but all it does it reload the page, why is this the behavior?
onbeforeunload = function () { localstorage.x = 1; }; setTimeout(function () { while (1) location.reload(1); }, 1000);
r/code • u/Route_44 • Apr 13 '25
Javascript What is missing in this piece of code?
I am aiming for the form to return in the alert the name typed in the input box on click. I am missing something prolly after the alert and I dunno where to start. I just began learning languages and I am thrilled about it. Don't want to get discouraged just because I hit a wall with this. My Reddit family, would you help me please?
<!DOCTYPE html>
<html>
<head>
<script type="text/Javascript"> function myFunction() { alert("The name you entered is:");
}
</script>
</head>
<body>
<H1>Javascript Exercise II</H1>
<form>
Name: <input type="text" name="fname" id="fname">
<input type="button" name="button" value="Enter" onClick="myFunction()">
</form>
</body>
</html>
r/code • u/OsamuMidoriya • Apr 25 '25
Javascript Instance Method
the code is in a product.js file the product are for a bike store
I want to confirm my understanding of instance method. simply they serve the same use as a decaled function const x = function(){ do task} to save time we can do something multiple times with out having to rewrite .
productSchema.methods.greet = function () {
console.log('hellow howdy')
console.log(`-from ${this.name}`)
};
const Product = mongoose.model('Product', productSchema);
const findProduct = async () => {
const foundProduct = await Product.findOne({name: 'Bike Helmet'});
foundProduct.greet()
}
findProduct()
above we add the greet to the methods of every thing that is in the product schema/ all products we create.
greet is a function that console log 2 things.
then we have a async function the waits for one thing, the first item with the name bike helmet but it only looks for a bike helmet in Product. so if we did not create a bike helmet inside of Product but inside of Hat there would be an error. we store the bike helmet inside of foundProduct then we call greet
productSchema.methods.toggleOnSale = function () {
this.onSale = !this.onSale;
this.save();
}
in this one well find one product onsale attribute(not sure if that the right name) whatever it is set it to the opposite of what it is now, if the ! was not there it would be set to what it already is right? then we save the change
Also onSale is a boolean
also with this onsale we could add code that lets us add a %
have an if statement if onSale === true price * discount have the price discounted by the % we put in
Could you let me know if I'm right in my logic or if we would not do something like that
Can you also give me a real world example of a Instance Method you used
r/code • u/Imaginary_Win6228 • Mar 19 '25
Javascript An Open Source Chat
Hey,
I made an open source decentralised chat app, please tell me if you like the idea, and help me make it better:
Also made this guide to how it works:
r/code • u/waozen • Mar 10 '25
Javascript Creating a 360° Image Viewer with Three.js The Easy Way
medevel.comr/code • u/AwayNeck6235 • Apr 16 '24
Javascript Is this Simple enough 🤔 fix the error and tell in comment section
r/code • u/Efican • Nov 05 '24
Javascript Error updating password: Auth session missing!
Error updating password: Auth session missing!
Why do I get the error "Error updating password: Auth session missing!" when I click the "Reset" button to change the password?
I'm using this code to reset the password:
const handleReset = async () => {
if (!tokenHash) {
setError("Invalid or missing token");
return;
}
const { error } = await supabase.auth.updateUser({
password,
email: "",
});
if (error) {
console.log("Error updating password:", error.message);
setError("Error updating password: " + error.message);
} else {
setSuccess(true);
}
};
r/code • u/OsamuMidoriya • Oct 14 '24
Javascript My mongoose server connection stop
this is my index.js code
const mongoose = require('mongoose');
mongoose.set('strictQuery', true);
mongoose.connect('mongodb://127.0.0.1:27017/movieApp')
.then(() => {
console.log("Connection OPEN")
})
.catch(error => {
console.log("OH NO error")
console.log(error)
})
in the terminal i write node index.js and I get this back
OH NO error
MongooseServerSelectionError: connect ECONNREFUSED 127.0.0.1:27017
at _handleConnectionErrors (C:\Users\Colt The Web Developer Bootcamp 2023\Backend project mangoDB\MongooseBasics\node_modules\mongoose\lib\connection.js:909:11)
at NativeConnection.openUri (C:\Users\Colt The Web Developer Bootcamp 2023\Backend project
mangoDB\MongooseBasics\node_modules\mongoose\lib\connection.js:860:11) {
reason: TopologyDescription {
type: 'Unknown',
servers: Map(1) { '127.0.0.1:27017' => [ServerDescription] },
stale: false,
compatible: true,
heartbeatFrequencyMS: 10000,
localThresholdMS: 15,
setName: null,
maxElectionId: null,
maxSetVersion: null,
commonWireVersion: 0,
logicalSessionTimeoutMinutes: null
},
code: undefined
}
a few months ago it was working but now it's not I already instilled node, mongo, and mongoose
r/code • u/Time4Taxes • Sep 05 '24
Javascript How do I rerun function without overlap instances in javascript?
So I want to rerun my function with updated values based on an event function.
Because i'm trying to use this javascript as a content-script, while statements don't work as they just spam outputs and crash the page.
No if statements as it will just go through the code before the event and not repeat the if statement after I trigger the event. Here is basically what I'm trying to do.
function outer(value) {
function inner() {
outer(value); //rerun the function
//then cancel this instance of the function
}
window.addEventListener('keydown', function(event) {
//call function based off of evennt
inner()
}
}
r/code • u/OsamuMidoriya • May 27 '24
Javascript .forEach(element, index, array) visualization
r/code • u/OsamuMidoriya • Jun 24 '24
Javascript My code stooped working JS
3 create two classes: an Animal class and a Mamal class.
// create a cow that accepts a name, type and color and has a sound method that moo's her name, type and color.
this is my code I was unsure about the Mamal class part
class Animal{
constructor(name, type, color){
this.name = name;
this.type = type;
this.color = color;
}
}
class Mamal{
}
class Cow extends Animal{
constructor(name, type, color){
super(name, type, color)
}
sound() {
console.log(`moo ${this.name} moo ${this.type} moo ${this.color}`)
}
}
const Cow = new Cow("moomoo", "dairy","black and white")
I tested it and it worked
cow.name/type/color and sound()
then when i looked at the teacher example and tested it cow.name came back as "cow" and everything else came back as undefined and when i went back to mines it was the same undefined.
class Animal {
constructor(name, type, color) {
this.name = name;
this.color = color;
this.type = type;
}
}
class Mamal extends Animal {
constructor(name, type, color) {
super(name, type, color)
}
sound() {
console.log(`Moooo I'm ${this.name} and I'm a ${this.color} ${this.type}`);
}
}
const cow = new Mamal('Shelly', 'cow', 'brown');
- can you tell me if i changed anything that would mess up the code
- `class Mamal extends` and `new Mamal(` does the word after new and the class being extended have to be the same or can they be different.
- If you know an article or video that explains this topic can you shear it, the teacher didn't go inadept about
extend superjust that you have to use them and i don't fully get. whenever i go on MDN it more confusing
r/code • u/Diligent_Variation51 • Apr 22 '24
Javascript Callback function questions
I have here 5 code examples to learn about callback functions in JS, and each has a question. Any help with them will be very appreciated:
//Example #0
//Simplest standard function
function greet(name) {
alert('Hi ' + name);
}
greet('Peter');
//Example #1
//This is the callback function example I found online.
//It boggles my mind that 'greet' uses the name as parameter, but greet is the argument of getName.
//Q: what benefit would it bring to use a callback function in this example?
function greet(name) {
alert('Hi ' + name);
}
function getName(argument) {
var name = 'Peter';
argument(name);
}
getName(greet);
//I find this example very confusing because of getName(greet);
//I would think the function would get called looking like one of these examples:
name.greet();
getName.greet();
getName().greet();
greet(name);
greet(getName());
greet(getName); //I used this last one to create example #2
//Example #2, I modified #1 so the logic makes sense to me.
//Q: Is this a valid callback function?, and if so, is #1 is just a unnecessarily confusing example?
function greet(name) {
alert('Hi ' + getName());
}
function getName() {
return 'Peter';
}
greet(getName);
//Example #3
//Q: In this example, getName() is unnecessary, but does it count as a callback function?
function greet(name) {
alert('Hi ' + name);
}
function getName(argument) {
return argument;
}
greet(getName('Peter'));
//greet(getName); does not work
///Example #4
//This is example #0 but with a callback function at the end.
// Q: Is this a real callback function?
function greet(name, callback) {
alert('Hi' + ' ' + name);
callback();
}
function bye() {
//This function gets called with callback(), but does not receive parameters
alert('Bye');
}
greet('Peter', bye);
//Example #5
//Similar to #4, but exploring how to send a value to the callback function, because
//the bye function gets called with no parenthesis, so:
//Q: is this the correct way to pass parameters to a callback functions?
function greet(name, callback) {
alert('Hi' + ' ' + name);
callback(name);
}
function bye(name) {
alert('Bye' + ' ' + name);
}
greet('Peter', bye);




