Questions tagged [javascript]

JavaScript (not to be confused with Java) is a high-level, dynamic, multi-paradigm, weakly-typed language used for both client-side and server-side scripting. Use this tag for questions regarding common implementations of ECMAScript, JavaScript, JScript, etc. JS does not typically refer to its ECMA-cousin, ActionScript.

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

Storing SVG settings in a global variable to retain its contents during resize - acceptable?

In the solution I've been asked to maintain (Meteor based app), there are several responsive SVG charts. When the page is loaded, settings for each chart are stored using the following: <input ...
Tania's user avatar
  • 1
-3 votes
0 answers
44 views

Advice on whether to build this program with PowerShell,Python or Javascript(Node)? [closed]

I have a website that plays a series of videos one after the other (think a playlist). I want to screen capture a recording of the videos. I have achieved this with: ffmpeg -f gdigrab -framerate 30 -...
Ralf_Reddings's user avatar
-4 votes
0 answers
61 views

SMTP Server from scratch in node.js [closed]

B"H I've seen many blogs and stack overflow questions about setting up nodejs to use a pre-existing smtp server, especially through modules like nodemailer etc. Some of what I've already seen: ...
B''H Bi'ezras -- Boruch Hashem's user avatar
0 votes
0 answers
53 views

Array structure for nested grouping (JavaScript)

I am currently struggling with how to solve nested grouping of data. The initial structure is given and my grouped structure below as well as my approach can be adjusted. My idea was to have the array ...
Dollique's user avatar
  • 101
0 votes
1 answer
75 views

HTTP redirect vs JS redirect

I have a Svelte web app exclusively for internal use, so there is no main landing page or registration, as accounts need to be created by the admin. Since the main page has no function as an ...
Jeremy Meadows's user avatar
3 votes
1 answer
143 views

Is it good practice to always use "use strict" in modern web apps? [closed]

I'm learning JavaScript and just came across "use strict". It sounds like to me it should always be in play but me being a beginner I was wondering if there are scenarios/environments when ...
Meester Moo's user avatar
0 votes
2 answers
242 views

Why did TC39 name JavaScript's array predicate functions `some` and `every` instead of `any` and `all`?

Python, Ruby, Rust, Haskell, Kotlin, C#, C++, Perl, MATLAB, SQL, and R all call their respective array predicate checking functions any and all. Is there any record of why JavaScript's designers ...
Alex Ryan's user avatar
  • 117
0 votes
1 answer
107 views

Why is `WeakSet` great for tracking circular references?

In MDN article on WeakSets, an example is given for using weak sets to avoid infinite recursion on circular references: // Execute a callback on everything stored inside an object function ...
Anton Strogonoff's user avatar
1 vote
1 answer
89 views

Is module scoped initialisation considered a bad practice?

A module app.js includes another module service.js. The service.js module/file contains some functions but also does some module scoped initialisations(registry variable). // service.js const ...
Cap Barracudas's user avatar
0 votes
2 answers
120 views

Variable assignment in ECMAScript specification in detail

I am trying to wrap my head around what the ECMAScript specification suggests about variable assignment. Introduction: Coming from Java, this is pretty straight forward. Variables get stored at a ...
tweekz's user avatar
  • 79
0 votes
2 answers
172 views

Local development for TypeScript library organized as mono repo with Lerna

I currently am developing a TypeScript shared library. The library needs to be imported in sections to minimize the imported bundle size, so I broke it up into packages with a monorepo with Lerna. ...
devleo's user avatar
  • 51
0 votes
2 answers
215 views

How to represent the absent of a field value in json response?

I am a react developer and writing the client on pure JS. I have sometimes missions to received data from server and send data to server. Now between the client team and backend rough discussion ...
Brk's user avatar
  • 21
1 vote
2 answers
93 views

JavaScript: Change prototype chain to morph objects from a deserialized JSON to business objects

This post assumes, that dtos on the UI side (SPA) could be viewed as business objects in almost all cases - except that the business logic is missing. I'm fully aware that a dtos first responsibility ...
morpheus05's user avatar
0 votes
2 answers
85 views

synchronize HTML5 or JavaScript video to realtime?

I will have multiple cellphones playing videos in an art gallery. The video content must be synced to the lights, which are synced to the real-world clock. As in, at 1:00pm the lights go out, 1:15 ...
prismspecs's user avatar
0 votes
2 answers
152 views

ECMAScript Primitives: Immutability vs Value Type

Coming from languages like C++, Java or PHP I've learned that there are Value Types and Reference Types. Value Types store values directly in the variable (in a box / memory location). Whereas ...
tweekz's user avatar
  • 79
26 votes
8 answers
9k views

Is it okay to hard-code table and column names in queries?

I've got a backend running on Node that executes queries on a PostgreSQL database. For these queries, table and column names are imported from a .env file, for example: const ID = process.env.ID_COL; ...
Lenny Zhou's user avatar
0 votes
2 answers
111 views

ECMAScript specification of primitives and objects

When reading through the ECMAScript specification, I noticed, it actually never mentions concepts like "pass by value" or "pass by reference". When looking at the assignment ...
tweekz's user avatar
  • 79
1 vote
3 answers
484 views

Best strategy to push client-side updates to server?

I'm just starting to build a web app using React.js, Next.js, Prisma, & PostgreSQL. In this web app, users can create "projects", which are represented by 10-15 rows in the database. ...
BurstWizard's user avatar
0 votes
0 answers
67 views

"Select All" in Table is now sending too much data to Server via API - Alternative Ways to Send to Server?

Outline of the current architecture of our web app outlining the issue I'm seeing Client-side app is React, talking to a server running the Play! framework via an API. On the page is a table that ...
bluedevil2k's user avatar
3 votes
1 answer
248 views

Do the maintainers of JavaScript remove features?

Really dumb question. I really like the new feature called "optional chaining" in JavaScript, and it's used in quite a few places in my front end code. However, I am concerned that whoever ...
Rongeegee's user avatar
  • 167
0 votes
2 answers
297 views

Extensive use of global variables in js codebase?

I've been tasked with refactoring/simplifying the architecture of a (relatively) large node.js codebase and it makes ample use of global variables. I don't have much experience with javascript so just ...
amy's user avatar
  • 111
1 vote
1 answer
405 views

What are the benefits of keeping npm packages up-to-date? [closed]

The company I work for is maintaining and developing a web application that uses many Node.js packages. A lot of these packages are really outdated. I can intuitively understand that it is good to ...
Akaisteph7's user avatar
1 vote
3 answers
180 views

How can I mix this grid to guarantee it being solvable in X minimum steps?

Note: This question is not about this particular instance of this grid with these exact words, but about any combination of words. I am programming a puzzle game where you have to arrange a grid of ...
Florian Walther's user avatar
1 vote
1 answer
155 views

Can I separate methods into different classes by passing in constructor properties from one class to another?

I am making a game of monopoly. Inside my game I have a Board class. The Board class has an array which contains 40 squares. Each square is a different class e.g. ChanceSquare, PropertySquare ...
Kevin Greetham's user avatar
1 vote
1 answer
70 views

How to develop data bound html with strong typing and intellisense?

I'm a huge believer in the value of Intellisense for showing you what syntax is expected and allowed (and also saving typing, though this is a secondary consideration). When you build a web component (...
Joshua Frank's user avatar
1 vote
2 answers
65 views

Crossbrowser testing FrontEnd apps in 2022

So nowadays, creating js & css that works the same across different browsers is less of an issue as to what it was a few years back. So let's say I have this Vue app that - Has CSS reset Include @...
Haim's user avatar
  • 119
5 votes
4 answers
312 views

Does my outer class adhere to the Single Responsibility Principle?

I often write front end apps with a generic MVC pattern. I use javascript but this questions is language independent and relates to OOP as a whole. I struggle to understand the SRP principle and I ...
Kevin Greetham's user avatar
0 votes
1 answer
316 views

Is this a good example of what a service layer is in MVC?

I am wondering what a service layer is in MVC. I like to understand concepts through a game of monopoly as it's relatable to a lot of people and fairly easy to explain whilst allowing for some good ...
Kevin Greetham's user avatar
0 votes
2 answers
228 views

How can I achieve polymorphism if MVC logic is on the controller?

First, let me start by saying I’m a JavaScript developer but any conceptual advice I’d imagine is identical if not similar to when dealing with MVC. During my learning, I stumbled across MVC and now ...
Kevin Greetham's user avatar
4 votes
1 answer
233 views

What would be the reason for using asynchronous programming on a web server?

I have a python/php background and just about to start work on a NodeJS project which is why I have this question. I have worked a bit on frontend JS but this is the first time I will be using JS for ...
Nikster2014's user avatar
0 votes
1 answer
164 views

Is it premature optimisation to test a condition to skip a small loop?

I have an array of entities which have an id property: entities: {id: string|null}[] = []; All items in the array are guaranteed to have id !== null and the array will not exceed 100 items. Now I may ...
lampshade's user avatar
  • 103
2 votes
3 answers
196 views

Eliminating combinations based on user input

I am stuck with this particular problem. To give context to the problem, I am developing a mobile app which helps with loading dangerous goods onto a truck. Ignore the size and weight of the dangerous ...
Saul Goodman's user avatar
-3 votes
1 answer
68 views

HTML Playground [closed]

I'm creating a service for creating web tools. The tool is a generated web page with some JS engine. The user can interact with the JS engine through the user interface. The user interface can be ...
christo's user avatar
  • 105
1 vote
1 answer
838 views

Difference between Resolvers and Controllers?

I may be overthinking it, but are controllers and resolvers the same thing in web applications? Coming from the MERN stack, everyone used to call these request processing functions "controllers,&...
twominds's user avatar
  • 129
1 vote
3 answers
233 views

Does it always take the same amount of time to retrieve the same thing from collection?

for example: const arr = [1,2,3,4]; const coordinate = [arr[0] + 2, arr[0] + 1]; here arr[0] is written out twice, when the code is executed would it literally go and find same value twice or would ...
link2name's user avatar
1 vote
1 answer
215 views

Is it a bad habit to use other class' "private" variables in Javascript

I've gotten this idea in my head that i shouldn't use a libraries variable, if the variable name begins with '_', as it is standard to write private variables that way. But now i'm thinking i'm taking ...
Jesper's user avatar
  • 143
0 votes
2 answers
1k views

Store static data in public folder as json file or directly in .js file?

I'm busy working on a website – somewhat new to this – and I don't quite know where I should store static data: in the public folder as a separate json file, or within the .js file as an object. In ...
AlePouroullis's user avatar
0 votes
1 answer
160 views

What can be done with closures that would be difficult or impossible to do without closures?

I am trying to understand what can be done with closures that would be difficult or impossible to do without closures. One use of closures I have found is to make an object's variables private, for ...
Christopher's user avatar
  • 2,029
-1 votes
1 answer
101 views

How to measure the impact of a website speed optimization

Given: You have a list of opportunities* that may improve the speed metrics of your website. For example Total Blocking Time (TBT) is one metric that heavily impacts the experience of a visitor. You'...
Jeremy Gottfried's user avatar
0 votes
2 answers
607 views

Should I use unnecessary function for readability sake

I am implementing if/else statement, by using function "inCase" to make it more readable: const size = 'small' const equals = str1 => str2 => str2 === str1 const inCase = (obj) => ...
Djordje Vuckovic's user avatar
0 votes
0 answers
393 views

Svelte & Vite Project - where/how to define constant values?

I have project where I use a url in various places. To prevent having to change it in all places, I would like to define it as a constant value in just one place which is referenced everywhere. But I'...
Corrl's user avatar
  • 101
2 votes
1 answer
160 views

Would invisible custom elements make sense?

The use case I was thinking about was something like this. I want to make a calendar for a month as a custom element, and I don't think passing up all the event data as JSON or something is the best ...
art-solopov's user avatar
0 votes
0 answers
72 views

Effective cache solution to have the newest data in React Native

Goal We have an app with different articles. I want to cache an article when the user has read it, but make sure that I display the latest data. I came up with this hook: React.useEffect(() => { ...
Gh05d's user avatar
  • 101
6 votes
2 answers
562 views

Is "this" in JavaScript out of fashion?

I'm not a frontend dev, but I recall that a few years ago, the this keyword was commonplace in frontend codebases. In recent years, I haven't seen this get used anymore. In the last few frontend ...
Newb's user avatar
  • 178
0 votes
1 answer
119 views

Verbs in Use Case name "Create User" [closed]

I'm struggling on how to name classes for use cases. Because I know that is "bad" to use verbs in classes names(Uncle Bob) but at the same time names of use case classes should explain what ...
Carlos Figueroa's user avatar
0 votes
0 answers
47 views

JavaScript: My logic traversing multi-dimensional arrays

Consider the following: Let's say below is the multi-dimensional, and you are given the starting point of [2, 2]. const WORLD = [ ['P', 'P', 'P', 'C', 'P'], ['P', 'M', 'P', 'C', 'P'], ...
Antonio Pavicevac-Ortiz's user avatar
1 vote
2 answers
954 views

How to authenticate front end with backend in an anonymous user flow [closed]

I have an API that will be exposed on the internet publicly, the primary use of this API will be initially by a ReactJs front end but in the future we'd be looking to open this up to other clients ...
A. Murray's user avatar
  • 171
0 votes
3 answers
102 views

Should we test private data (static objects in this case) to make sure it maintains its structure?

I had a discussion at work about whether to unit test a private static object we're using as data for a public component. const data = { 45: { name: 'John' }, 2: { name: 'Patricia' }, 27: { name: '...
Jose Daniel Vivar Personat's user avatar
8 votes
3 answers
12k views

How do you 'merge' several JS files into one? [closed]

New Web Dev here. Recently I got into DOM manipulation with JS, everything was sweet with one-page websites, but then I tried with projects with many html files and that's when I got confused. It's a ...
JosueMagnus12's user avatar
-2 votes
1 answer
81 views

Creating a promise based API, from a message based API

I'm building some software that behind the scenes needs to communicate with hardware via a "message" API, over a named pipe. For example, I can send this message: <?xml version="1.0&...
i.brod's user avatar
  • 125

1
2 3 4 5
43