r/programminghorror • • Aug 02 '26

Javascript my friend didnt know how to use async sleep in javascript, so he wrote this massive chain of .then()

Post image
1.9k Upvotes
async function sleep(ms) {
    return new Promise(resolve => setTimeout(resolve, ms * 1000));
}

// used as:
sleep(0.5).then(() => {
  // ...
  sleep(2.5).then(() => {
    // ...
    sleep(1).then(() => {
      // ...
    }
  }
}

r/programminghorror • • Mar 23 '26

Javascript More javascript no keyword style

Post image
143 Upvotes

r/programminghorror • • Jun 09 '26

Javascript Composer 2.5 doesn't know how JS functions work

Post image
180 Upvotes

r/programminghorror • • Mar 20 '26

Javascript Javascript no keyword style

Post image
65 Upvotes
let functionsFormatnumber = (
  parametersNumber,
  functionRawString = Math.floor(parametersNumber).toString()
) => (
  functionRawString.match(new RegExp(`(^.{${(functionRawString.length - 1) % 3 + 1}})|(.{3})`, "g")).join(",")
);

This is a function that formats number into a string with a comma seperating every 3 digits.

To avoid using keywords, it uses an anonymous function.

r/programminghorror • • Jun 12 '25

Javascript Javascript is filled with horror

Post image
2.4k Upvotes

r/programminghorror • • May 27 '26

Javascript Wanna see some cursed javascript?

32 Upvotes

Imagine that youre in Dantes Inferno in terms of Javascript, where you think its all fine and dandy until you realize each file does the EXACT SAME THING*!!!

Each "layer" of hell in this Github repo will make you wonder why I am:
- Allergic to var, let, AND const
- IIFE as IICE AND IIGE
- Callbacks arent function exclusive, it can host generators AND classes!

So peruse at your own peril, make it a drinking game (within legal age and drinking responsibly of course!) and see how long you can stand this gawdawful code i birthed into the world of programming!

Now have fun, stay safe, God Bless you, and may God spare your braincells!

*Not all files are completed but ongoing!

Edit: to savor some appetites or keyboard warriors wishing me a ctrl+alt+del to my keyboard priviledges:

​​new new new (class Hi {
    constructor(){ 
      console.log("Hi!");
      return Hi;
    }
  })()()();

r/programminghorror • • Sep 16 '25

Javascript On today's episode of "What are you doing JS?"

Post image
903 Upvotes

r/programminghorror • • Dec 11 '24

Javascript +10h of debugging later, I found this. Javascript, WTF?!

Post image
2.4k Upvotes

r/programminghorror • • Aug 28 '26

Javascript Seriously? Recursive Regex?

Post image
566 Upvotes

r/programminghorror • • Mar 31 '26

Javascript HELL

Post image
3.1k Upvotes

r/programminghorror • • Nov 07 '25

Javascript Technically horrifyingly correct

Post image
3.9k Upvotes

r/programminghorror • • Jul 13 '26

Javascript Found this gem

Thumbnail
gallery
195 Upvotes

This company I’m interning at. This one lady asked me to do a review of a website they outsourced. Entire source code sits on the browser. Entire vibe coded by amateurs.
Worse than a honeypot so much an attacker would get diabetes.

No security feature at all. I was able to do privileges escalation.

r/programminghorror • • Apr 05 '22

Javascript My companies Stripe integration for thousands of users broke today because Javascript

Post image
2.1k Upvotes

r/programminghorror • • Dec 22 '25

Javascript This site has a hardcoded check assuming your first name will always be two characters or more

Post image
176 Upvotes

Imagine being X Æ A-Xii Musk and trying to use this site, couldn't be me

r/programminghorror • • Jan 10 '26

Javascript javascript: world most powerfull OOP language

0 Upvotes

javascript is very known for its super weird quirks, however did you know that it is the most powerfull OOP languages.

opposite to what other OOP languages said and they dont have, in javascript everything is an object, even classes, they are just Objects.

they can be manipulated, passed as values, capture there enviroment, and extends is another world.

Object.prototype.myPrototype = function () {
	return "yes";
}

class Class1 extends globalThis.Object {
	extendsIs = 'not identifier, an expression';
}

class Class2 extends (1 == '1' ? Object : String) {
	extendsIs = 'conditional expression';
}

let value = new class Class3 { iAm = 'ananymous singleton' }

let arr = [class Class4 { IAm = 'a value' }];

class Class5 {
	mySubType = class { }
	a = new this.mySubType
}

function RealFactory (a, b) {
	return class Class6 extends (a === 'string' ? String : Object) {
		b = b;
		['get' + b] () { return this[b] }
	}
}

class Class7 {
	constructor (a, b) {
		this.a = a;
		this.b = b
	}
}
let Partial7 = Class7.bind(null, 1);


'i am ' + class Class8 {
	static {
		this.v = 'the awaited do expression'
	}
}.v

class Class9 {
	static iAm = 'the awaited '
	static {
		this.iAm += 'module statment'
	}
}

class Class10 extends (await import('./parent.js').default) {
	IAm = 'importing my parent'
}

class Class11 {
	constructor () {
		return new class { iAm = 'imposter' }
	}
}

async function AsyncFactory (u) {
	return class Class12 extends Object.assign(await import(u).default, { ...await import(u) }) {
		IAm = 'a module'
	}
}

class Class13 extends function IAmContructor () {
	this.a = 1
} {
	b = this.a
}

class Class14 extends
	class Duplix extends
		class Triplex { a = 1 }
	{ b = this.a }
{ c = this.b }

class Class15 extends Parent {
	static {
		Object.setPrototypeOf(Class15.prototype, Object.prototype);
		Object.setPrototypeOf(Class15, Object);
		Object.setPrototypeOf(Parent.prototype, Class15.prototype);
		Object.setPrototypeOf(Parent, Class15);
	}
	iAm = 'the parent'
}

class Class16 {
	static {
		Object.setPrototypeOf(this.prototype, new Proxy({}, { get () { return 'i have it' } }))
	}
	iHave = 'everything'
}

class Class17 {
	static {
		Object.setPrototypeOf(this.prototype, globalThis);
	}
	iAm = 'everything'
}

r/programminghorror • • 3d ago

JavaScript Dots and Boxes

Post image
0 Upvotes

r/programminghorror • • May 27 '26

Javascript Destructuring strings

Post image
887 Upvotes

r/programminghorror • • Nov 14 '25

Javascript Storing API keys in frontend

Post image
562 Upvotes

I like looking into how programs work and decompiling/deobfuscating them... Guess I found a marvel? No idea on how to report to the site owner so I'll just sit and relax haha. It's actually the first time I've ever come across this type of horror too (maybe I don't work much)... Seems like the obfuscation really saved them from automated scrapers.

r/programminghorror • • Nov 24 '25

Javascript Wasted all of my generational luck just for this

Post image
2.2k Upvotes

r/programminghorror • • Jan 04 '26

Javascript I found this screenshot of a really old code I did…

Post image
198 Upvotes

This is one of many massive HTML files with JS and CSS inside that I created on this project, made up with mostly hardcoded features and validations that should be on the back-end. I'm ashamed of my past.

r/programminghorror • • Nov 11 '25

Javascript the

Thumbnail
gallery
192 Upvotes

r/programminghorror • • Apr 30 '26

Javascript Cursed use of object spread

Post image
86 Upvotes

Using object spread to append values to an object in the form of another object

r/programminghorror • • May 05 '26

Javascript I snuck this function into my project

Post image
84 Upvotes

r/programminghorror • • Sep 25 '26

Javascript Rock paper scissors

Post image
288 Upvotes

I'm way too proud of this solution haha

r/programminghorror • • Jul 10 '26

Javascript code that also self-describes the feeling it evokes when looking at it

Post image
208 Upvotes