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
0answers
4 views

Playing a stream of ArrayBuffers with data having mimeType “video/webm;codecs=vp8,pcm” in browser?

I am sending a video stream of data to another peer and want to reassemble that data and make that stream the source of a video element. I record the data using the npm package RecordRTC and am ...
0
votes
2answers
49 views

Setting custom callbacks in a Javascript applet?

I'm designing a 3D visualisation applet in Javascript. When used, a Canvas will be created and placed inside an HTML element on a webpage, specified by the developer who is implementing the applet. ...
1
vote
0answers
45 views

Setting width/height of unknown images for lazy loading

I have a site where users upload images & can all be viewed on a single page by other users. I want to lazy load images as the user scrolls instead of loading all initially. This is easy enough, ...
2
votes
3answers
124 views

Good ways to prevent client side logic duplication without HATEOAS?

I know HATEOAS can be a bit of a heated topic. Some people like it, some people don't. That is not what I want to discuss. What I want to discuss is what technology other than HATEOAS (or some form of ...
2
votes
2answers
116 views

Providing same API implemented in multiple languages

Our budding (currently internal) API deals with building information models, originates in our main application written in c++. There is a small implementation of it in C# for easy interop with other ...
0
votes
1answer
41 views

Best technique for sending multiple files in a single JSON post with Vue/javascript?

Using Vue/Electron to post to rails/Postgres backend. Is there a common design pattern/approach to posting multiple audio file objects BUT in a single post request? My current process (which works, ...
-4
votes
0answers
56 views

MVC GUI architecture for multiple Views per Controller

I'm starting a Geographical map application in Js which will handle hundreds, maybe thousands of 3 different types of elements. I'm considering MVC approach but I don't know how would be the best way ...
-2
votes
1answer
131 views

Should I repeat my code or use if statement?

A question from a friend: I have multiple usages for the same code, let's say a vertical HTML card. I change the title and a lot of data based on the react component. it feels unnecessary performance-...
2
votes
1answer
35 views

Exception handling with adapter design pattern in JavaScript

I am using an opencv.js Web Assembly build in the browser. The build comes with a JavaScript interface to call the WASM functions but it does not provide any memory management. For example every time ...
-4
votes
0answers
29 views

How to assign random words or phrases to a list of set terms

I am writing an algorithm which uses Machine Learning to categorize posts right after they are created in my database. I have a set of 370 terms that another algorithm uses to display it to the right ...
0
votes
1answer
54 views

Structuring a Compiler in a Dynamic Language (JavaScript)

For learning purposes, I'm trying to build a compiler in JavaScript for a tiny custom language and turn it into WASM. So far, I've got a lexer and parser, that turn my code into an AST, my question is ...
0
votes
0answers
24 views

Handle multiple buttons with different API IDs in a HTML table

Ok, so my scenario goes like this: I am building an API of financial transactions. Backend does not matter for this problem, the only thing is that the API has a route /users/:userid/transactions/:...
0
votes
0answers
19 views

I need help understanding how to deal with multiple authentications in a VueJS app

I have a VueJS app, which currently authenticates with JWT to a Spring Boot back end. I would like to make use of Firebase, so I can take advantage of the reactivity it provides. i.e. instead of ...
0
votes
2answers
84 views

Unit testing multiple features in one test

I'm writing a small utility class to create an abstraction for addEventListener (JavaScript/DOM) Let's say I have to test for these features: Single event target with a single event Multiple events ...
2
votes
1answer
141 views

Is it an antipattern to pass an object that stores the application state from one function to another?

The program is written in JavaScript. To give you a rough idea what I am thinking of: function State() { return { color: 'green', size: 100, // ... there are other properties here } } ...
-1
votes
1answer
94 views

What are downsides to opening local html files in the browser?

Let's say you have a scenario where you want to build a simple web stack (html/css/js) prototype to share with someone. I am a little unclear on whether or not I want/need to use a small web-server to ...
-3
votes
1answer
35 views

Testing a React component which receives a function as a prop

Suppose there's a root <App /> which houses multiple components, one of them being, say <SearchBox />. App component houses the app state (such as searchResults array) and iterates the ...
4
votes
1answer
164 views

Should published npm packages target ES5 syntax?

A bit of background: I've been using Webpack with babel-loader for a while and overall the experience has been hugely positive. Yesterday, I published an npm package of my own (to a private registry), ...
4
votes
3answers
411 views

Is this extensive usage of closure a known (anti-)pattern? And does it have a name?

I often use function closures for storing data (e.g. database URL), which doesn't change between function calls. Is this an (anti-)pattern? Does it have a name? While developing apps, which recieve ...
2
votes
2answers
221 views

How do modern JS engines terminate unresponsive scripts?

I'm trying to implement a safety feature that puts a timeout around a huge function call. Pretty simple, I thought, but it turned out much harder than expected; there's no built-ins for this in any of ...
16
votes
10answers
5k views

Are immutable objects important only in multi-threaded applications and if so, how are shared immutable objects useful?

I think the answer to the first part of my question is, "yes" -- no point in making objects immutable in a single-threaded application (or I guess in a multi-threaded application if that ...
0
votes
2answers
69 views

How can I cleanly set up debug logging in my javascript frontend?

I basically want to be able to "turn on debug logging" like you can do with many applications that run in a shell. The naive way of implementing it would be to insert a statement like this ...
0
votes
1answer
48 views

How to add event handlers to an object containing elements

I am new to JavaScript, I've done most of my coding in Python, and haven't found a clear answer to this question. If I have an object containing element ids and function parameters, and I want to add ...
1
vote
1answer
69 views

Digital Signature for PDF files through Web Application

We are developing a Web Application for manage dental clinics. The app can generate PDF files through the PHP backend (for example invoices, quotes etc.). Each of those PDF file needs to be digitally ...
-1
votes
1answer
151 views

Is async/await a good alternative for locks in JavaScript?

Yes, I know, the question title is a bit provocatory. But let me explain. I needed to execute a sequence of async tasks in JavaScript. They are async because I need them to be non-blocking, but I ...
23
votes
8answers
10k views

Can I use additional parameters in recursion problems?

Okay, I was being interviewed at a company and the interviewer asked me a recursion problem. It was an online interview, so, he had set up the problem statement and a function signature on CodeSandbox ...
3
votes
2answers
216 views

What is the rationale for making certain methods for data types static?

In C#, for instance, there are static methods for telling if a string is null or empty, finding an element in an array, clearing an array, etc. However there's an instance method for replacing ...
1
vote
1answer
85 views

How to manage 2 libraries that do mostly the same things in a project?

I am encountering a design problem on a new project. I have chosen the library Luxon (https://moment.github.io/luxon/) because I think it suits this project perfectly. Date-fns (https://date-fns.org/) ...
0
votes
0answers
51 views

Does v8 have nested stack frames?

In chapter 4 of the Zone JS primer the following is mentioned: So far, we have discussed how zones are created, forked and how they maintain their state across asynchronous operations. Zones are ...
-1
votes
1answer
45 views

Is there a way I can make something happen on my nodejs server at a particular time

I'm not sure that I'm even asking the right question so I hope you guys can point me in the right direction here. I have a full stack web app which has listings (think eBay, Gumtree, Craigslist) and I ...
0
votes
0answers
30 views

When designing an API in Javascript with closures, should I provide singletons or factories for directly creating objects to clients?

I'm designing an API in Javascript part of an Angular with typescript project. I have involved later in this project implemented. There is a DataStorageService which I checked from git logs that ...
0
votes
1answer
80 views

Use nullable or undefineable as object type?

This come with a debate with my colleague that I'm using nullable object type. type Value = Node | null const [v0, setV0] = React.useState<Value>(null) const [v1, setV1] = React.useState&...
22
votes
8answers
7k views

Should child nodes have a reference to their parents?

Let's say you are engineering a chat room software. let client = new Client(); let room = rooms.FindRoom(); room.addClient(client); This room (parent) now has a client (child). client.on('message', (...
-1
votes
1answer
62 views

Mutexes at application logic level

In my node.js app I have a async function that fetches remote documents and caches them on the disk. Upon a retrieval request for a document first checks the disk, if found loads it from the disk ...
-2
votes
1answer
81 views

How to start developing a well architected Javascript Library?

I want to start developing an. open-source javascript library. I can see other open-source libraries are well structured. They have src, dist, test kind of folders, etc. Which is making me very ...
0
votes
0answers
17 views

Sanity Check Request on WordPress Problem involving Importing XML into Gravity Forms plugin

Disclaimer: This is a conceptual question and so I'm posting here rather than stackoverflow or wordpress.stackexchange Okay, so I need to import XML data into WordPress and parse it to populate a form ...
0
votes
0answers
32 views

Is XSS by html event injection a problem in this client-side sanitization?

I'm making my own client-side router which dynamically requests html pages from Firebase hosting, and the website uses Cloud Firestore with secure rules. Is there any XSS HTML event js injection ...
0
votes
0answers
36 views

How to integrate App package into web and desktop apps using Typescript and React?

I'm building an application that will be served via browser and on desktop via ElectronJS. I'm using Typescript and React. I have separated the whole app in the following packages: ui: it has all the ...
-2
votes
1answer
107 views

HTML LocalStorage vs Broadcast Channel: When To Use Each

What are the use cases between using BroadCast Channel and LocalStorage? We are looking into communicating between two browser windows or tabs. Researching for good case scenarios between the two. ...
-3
votes
2answers
189 views

Should I use Flask w/ Javascript OR a Javascript UI that calls a Flask / Connexion API?

I recently wrote a data management tool in Python & SQLAlchemy. Now, I need to put a web UI on it. While I want to start small, there is some need for interactivity, like drag and drop in tables, ...
-3
votes
1answer
65 views

Might be inheriting a php spagetti project. Full rewrite in different tech stack? [duplicate]

I'm in dire need of some help. My background is from python, js and ruby, with using frameworks to provide good structure. A potential client has an internal app which does quite a bit of stuff. This ...
0
votes
4answers
194 views

What prevented compiled languages from being adopted on the web originally, as opposed to JavaScript?

Since my previous question was closed (https://stackoverflow.com/q/62354455/1173166), I thought this would be a better place to ask the question. Original: JavaScript we designed specifically for ...
-3
votes
1answer
48 views

Does using a destructured object as function arguments make sense?

Once upon a time we did this /** * Function that does lots of things * @param {boolean} state * @param {number} max * @param {string} set * @param {number} timeout * @param {boolean} bail * @...
10
votes
7answers
2k views

Should you make use of 'accidental polymorphism'?

Sometimes I find myself in situations where just by happenstance two things can be treated the same way. But they aren't truly the same, it's just coincedence. Let me give an example, imagine we are ...
0
votes
2answers
147 views

How to handle different types of errors in Clean Architecture?

So, in the process of creating a user there are 4 possible outcomes: Username is already taken Email is already taken Username is invalid Email is invalid Here is what I have in the controller for ...
-4
votes
1answer
43 views

Message Strings in Backend

Its ok to have hardcoded strings on backend? Example: Log.e("Error connecting to the database") The text "Error connecting to the database" should be hardcoded there? Or should it be in a separated ...
1
vote
2answers
77 views

Where should I put the .scss files in the scaffold?

I have developed an open-source vue.js scaffold which is based on my exprience and study on various vuejs projects. Currently it has a good structure(i think), but i'm nervous about is it good ...
-1
votes
1answer
81 views

Good representation for list of items that can be grouped together

I am building the frontend of a web app in JavaScript that manages list of past events. It basically has the following requirements: Events are displayed in a vertical list. Events can be moved to ...
0
votes
0answers
55 views

Conditionally filtering dependency-injected async data?

I have a NodeJS application which I've built around dependency injection. The app can run any combination of its functions (modules) at the same time, and any modules that request data from the same ...
-3
votes
1answer
40 views

Do I need MongoDB (or another type of database) to authenticate with Google?

I'm creating a web application using Node.js and Pug, and have recently been looking at adding external OAuth authentication to this site, using Express and Passport.js. I've found a lot of examples ...

1
2 3 4 5
41