Questions tagged [javascript]

JavaScript is primarily a language focused on web development. Being a monopoly on the front end and having Node on the back end. Use this tag for questions regarding vanilla JavaScript; optionally tagged with an ECMAScript version. If you are using a preprocessor such as TypeScript please tag with that too.

Filter by
Sorted by
Tagged with
0 votes
0 answers
25 views

security risks of Function()

Im trying to create an object of functions, but im concerned about the security risk of Function(), im planning to stringify the object_formulas and store it in a database so it can be updated ...
Dylan's user avatar
  • 1
5 votes
2 answers
399 views

Optimizing for() loops on Roman Numeral Converter JS

I'm looking for some feedback on this converter I made. It works just fine for the instructions I had, but I'm wondering what else could be done to improve it or if there's a better aproach to doing ...
Ignacio Vior's user avatar
-1 votes
0 answers
60 views

Merging objects recursively

Would like to ask if my function to merge two objects recursively is correct. Whenever an item of newObject is an object/array and the same document item is not, ...
user280307's user avatar
2 votes
3 answers
1k views

Math calculation JavaScript. Am I using Objects correctly? Can I use methods / functions to shorten my code further? Also error logging?

Context- CRM system, front-end form. Requirement- Within a form users have to give a rating to a section based on user inputs, each rating has different weighting. The rating is stored in an option ...
BenDev21's user avatar
-1 votes
0 answers
31 views

Color diffusion effect

Color diffusion effect developed around opacity and transition css properties of two overlapped div elements. ...
user avatar
4 votes
2 answers
146 views
+50

Is it possible to make this Minecraft Bedrock addon script less resource intensive, so that it no longer triggers performance warnings?

Following the notice that block events will be removed in a future update, I have been implementing custom block mechanics (such as crop growth and groundcover spreading) using server-side scripts ...
Quack E. Duck's user avatar
0 votes
0 answers
33 views

Event source with event driven architecture [closed]

Implementation to source events with configurable quantifier and frequency of events and a visual indicator for the generated event and for the frequency. One tap on visual indicator changes the order ...
user avatar
2 votes
1 answer
243 views

Efficient browser `StorageEvent` handling

I have this class EfficientStorageEventProvider, which is responsible for efficient handling of StorageEvent ...
Ivan Ivanyuk's user avatar
1 vote
0 answers
28 views

Refactor Node.js Logging Library for Improved Readability

I have a Node.js logging library that applies ANSI styling for text formatting. Currently, the code contains some redundancy and could be refactored for better readability. I'm particularly interested ...
Dinesh Basnet's user avatar
-1 votes
0 answers
26 views

Surface scribble effect

Animated scribble effect, developed around Math.random function, supporting configurable scribbling direction (inward, outward), pause and clear scribbles with a ...
user avatar
1 vote
0 answers
27 views

Svelte - Modal window with dark background and appear/disappear animations

I created this code in Svelte which will show a modal and remove it when the background is clicked, based on a native JavaScript implementation I wrote earlier. In the *.svelte files, I put the focus ...
musava_ribica's user avatar
1 vote
0 answers
34 views

JavaScript: Retry wrapper for the fetch-API

I know there are many good libraries for this, but to understand the issue better, here is my own basic attempt. The fetch will be retried if it fails with a promise rejection or the response ...
Amaterasu's user avatar
  • 205
0 votes
1 answer
54 views

Manage repetitive/similar structures (logging & try/catch blocks)

I'm writing a web bot using puppeteer and I'm logging (using winston) every action the bots does and running it inside try/catch blocks. For automating these processes and avoid code repetition I ...
lapdoggo's user avatar
1 vote
0 answers
40 views

Pulse effect on event driven architecture

Event driven architecture implementation resembling pulsing with configurable softness (intense, mild, subtle), pulsing mode (inhale, exhale), pulsing frequency (plain, dense, breathe), number of ...
user avatar
0 votes
0 answers
28 views

Bidirectional typing effect

Implementation supporting both typing directions from left to right and from right to left. It also supports alternating typing directions and configurable letter spacing. With monospace font the ...
user avatar
0 votes
0 answers
41 views

Ascend animation followed by hover effect

This CSS code creates an animation that describes a random movement using the CSS transition property for box-shadow which ...
user avatar
0 votes
0 answers
28 views

Colorproof dust effect (second thought)

The colorproof dust effect could be enhanced with positionproof feature getting the position of the dusted element (dust container) from its getBoundingClientRect ...
user avatar
2 votes
0 answers
145 views

Optimizing Performance of Minimum Translation Vector (MTV) Calculation in SAT Collisions

I've implemented a Collison Manager using the Separating Axis Theorem (SAT), and I'm looking for suggestions to enhance the performance of the Minimum Translation Vector (MTV) calculation. The ...
Mark Vaaz's user avatar
2 votes
0 answers
30 views

Colorproof dust effect

A combination of various css transitions (background-color, box-shadow, opacity, ...
user avatar
0 votes
1 answer
58 views

A Chrome extension for analytics debugging: code to render the popup

I made an extension and got it to the point where it does what I want how I want. At this point, I have a little capacity to work on code refactoring, readability and such. And I would love some ...
BNazaruk's user avatar
  • 109
2 votes
1 answer
85 views

Consuming sharded database using node.js

I think the only big improvement that can be made is to check which shard to query based on the userIds of the followed users. One easy way is to check the last ...
Sayaman's user avatar
  • 341
5 votes
2 answers
106 views

Seeded PRNG in JavaScript and Python yielding same results

So I need a PRNG in Python and JavaScript that yields the same results, which is the reason I can't use the built-in methods. It doesn't have to be very good or even cryptographically secure, since it'...
Amaterasu's user avatar
  • 205
1 vote
0 answers
22 views

InlineWorker class to implement a fancy inline dedicated worker

In my deep dive into the study of workers I started trying to create a worker that could run on the same file but return values from the sent function. Something like this but more sophisticated. <...
Leonardo Rick's user avatar
3 votes
1 answer
119 views

Handwriting progressive drawing

Implementation to progressively draw symbols, when provided with symbol implementations it supports any type of symbols, though for the review purpose just two hand written latin symbols are supported ...
user avatar
-1 votes
2 answers
50 views

I would like to horizontally align a HTML element to a specific place in the document [closed]

How can I horizontally align one HTML element to one elsewhere in the document? I came up with this solution aligning “aligned text” with “| text after alignment”, but I think that it is not good ...
matj1's user avatar
  • 9
1 vote
2 answers
168 views

Virtual scroller Vue component

Problem The scrolling looks smooth on Windows, but very laggy on Linux (Webkit webview and Webkit browsers). Any thoughts on what could be optimized or what's obviously broken? Demo playground: https:/...
AlekseyHoffman's user avatar
0 votes
0 answers
30 views

Calendar Grid with layering of multiple events

My attempt at coding an adjusting calendar grid. It seems to work in most cases I've tried (although I haven't tested it exhaustively yet) but my DOM is a bit rusty and I wonder if there's better ways ...
Mark Green's user avatar
1 vote
0 answers
40 views

Node.js Image Optimization Service Using Sharp Library

I've developed an image optimization service in Node.js, leveraging the Sharp library for image processing. The service is designed to handle various image formats, offering resizing and format ...
David Chochol's user avatar
1 vote
1 answer
125 views

auto image slider in js and css

I was just wanting a code review on this image slider I made. I don't have anyone else to give me their opinion on the code I write outside of work, so I'm asking here. okay so i had made an image ...
hestia's user avatar
  • 11
5 votes
1 answer
169 views

Tic-tac-toe with JS

I am a beginner and was hoping for some honest feedback on my js code. I struggled quite a bit on this, I did ask gpt to explain some concepts which I find it’s good for but wrote it all myself. <...
FeDev's user avatar
  • 61
2 votes
2 answers
61 views

Paragraph structure template generator refactoring

This is an app that generates random statement types, and basic conjunctions. How to improve its readability and function? How to deploy this code app online? This is the GitHub repository: https://...
Attila Vajda's user avatar
0 votes
0 answers
26 views

Video resumer web extension

made a Firefox extension for resuming videos, because on Firefox Android, YouTube videos that have been out of focus for a while, reset their playing time. There already exists a firefox extension for ...
hanshenrik's user avatar
1 vote
3 answers
204 views

programmatically update a <td> element per table row

A table that gets updated with new values as soon as they arrive. Each value is in its own row: An array of objects representing each a quote (ticker and price) ...
dhiaagr's user avatar
  • 65
4 votes
0 answers
74 views

Complete html5 platform game as a snippet

I made a complete little platformer game as a code snippet. The goal is to try to keep jumping on the enemies without touching the ground to increase score. I used Tad's Basic Game Objects, an open ...
mrall's user avatar
  • 41
1 vote
1 answer
57 views

How to encapsulated javascript code using imutable method?

I have this code, but I need to return pure functions instead the mutating functions. Is it possible? Perhaps using OOP? I don't know how to improve it. I tried to return the values in each function, ...
Wesley Souza's user avatar
0 votes
1 answer
82 views

Advent of Code 2023 day 1: Trebuchet in JS, part 2

The task involves analyzing a bunch of lines containing lines of text. Each line represents a calibration value that needs to be recovered by extracting the first and last digits and combining them ...
konijn's user avatar
  • 33.1k
2 votes
1 answer
68 views

Advent of Code 2023 day 1: Trebuchet in JS

The task involves analyzing a bunch of lines containing lines of text. Each line represents a calibration value that needs to be recovered by extracting the first and last digits and combining them ...
konijn's user avatar
  • 33.1k
1 vote
1 answer
69 views

String represents a road. One character travels on the road obeying the stops - Code challenge (advent.js day 5)

This is my code to solve the 5th Adventjs challenge. In that link you can read the instructions. How can I improve it? It's a bit messy... and I'm repeating some part of the code. All must be in just ...
Sofia Chardin's user avatar
4 votes
1 answer
63 views

access arrow data

I am fetching arrow tabular data from an API. The content-type of the response is application/vnd.apache.arrow.stream. In my react code, I am trying to read the ...
Deb's user avatar
  • 41
2 votes
1 answer
97 views

Move timestamp to the next Monday 10:01 AM [closed]

I've been battling ChatGPT for hours now and can't get satisfied with this simple algorithm in TypeScript. These two (hopefully correct) TypeScript+ReactNative solutions should move the timestamp ...
Slazer's user avatar
  • 119
1 vote
2 answers
135 views

Rubik's cube scrambler with timer and list of solves

This is a work in progress Rubik's Cube scramble generator with timer and list of solves. The list of solves is stored using localstorage so that it stays on page reload. A solve can also be deleted ...
HTMLNerd_1's user avatar
2 votes
1 answer
91 views

My code.org Game Lab project is running really slowly, how can I optimize the code further?

I'm working on my final project, and it is a game made with Java Script in code.org's Game Lab. The code worked fine, and it was not slow at all, but as I worked on it, it became much slower! The ...
Renier Jr.'s user avatar
0 votes
3 answers
122 views

A Tic Tac Toe Game Made With Javascript

I just finished creating a Tic Tac Toe game in Javascript, but now am wondering if there are ways I could improve upon the code I've written for it. Mind the lack of CSS here. ...
Delfino's user avatar
  • 509
1 vote
0 answers
63 views

Variable button increment picked from an input:range in React 18

I'm a newbye in React. I created some simple Components to practice. For now, I'm using class Component (I want learn either class COmponent or function COmponent). I would know if I projected ...
Nick's user avatar
  • 111
0 votes
0 answers
68 views

Html and CSS editor that runs and saves code

I decided to create this project to put my JS skills to the test mostly, and it works well. It is a HTML and CSS editor that saves your code to localstorage and ...
HTMLNerd_1's user avatar
4 votes
0 answers
169 views

Optimizing a Wordle Solver in JavaScript

I have written a Wordle solver in JavaScript. The solver generates a decision tree. For each word, it generates all possible feedbacks patterns for that word, it then selects for each pattern the word ...
Cortex's user avatar
  • 440
1 vote
1 answer
119 views

Is this string-comparison function safe against timing attacks?

Here's a JavaScript function that check the equality of input and secret strings, trying to do that without leaking information ...
Azerum's user avatar
  • 23
1 vote
1 answer
73 views

Tracking people's check-in and check-out at an event

I have some logic that helps me calculate the data for a summary of an event, which should be rendered as something like this: ...
Andrey Namikaze's user avatar
3 votes
1 answer
240 views

Find the closest named color

I have a .json file with name (string) and RGB (r, g, b: numbers) with 30.000 key-value pairs. I am looping the json multiple times per second to find the closest name to a given RGB color. Any idea ...
Relik8's user avatar
  • 31
2 votes
1 answer
57 views

JS animated string builder

Today, I tried to write a simple function that would display the characters of my string one by one by iterating over a string containing the letters of the alphabet and showing the steps on the ...
Luca Natale's user avatar

1
2 3 4 5
192