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
-1 votes
2 answers
154 views

Using OOP objects mapping to DOM elements vs. querying the DOM repeatedly?

I'm trying to make better use of OOP, but I don't have good instincts for this yet and I sometimes worry I'm making things more complicated and/or less efficient. I'm wondering what is the best way to ...
user avatar
-2 votes
1 answer
38 views

Do I need a separate backend (Express) for an Angular project if using AWS for data storage?

So, I'm working on developing my first Angular project with/for a friend of mine and I have a design question before I really get started with things. I'm going to be storing persistent data on AWS ...
user avatar
0 votes
2 answers
132 views

Dependency injection vs other design pattern

I really don't love the design pattern I've established here. It's kind of DI but not really, and the alternative is more constructor based DI, but I also hate it. Maybe it is because it is JS and ...
user avatar
1 vote
1 answer
1k views

Rabbitmq create queues dynamically based on number of users

I have a scenario where I have to route a list of messages that I get to respective users. For suppose if I have messages = [ { text: 'hi', user_id: 1 }, { text: 'hi', user_id: 2 }, { text: 'hi',...
user avatar
4 votes
3 answers
2k views

Should try-catch blocks be used when calling functions that already have them?

In JavaScript, if I have try catch blocks in a function that is meant to be called from another function, should I also put them in the calling function or just let the called functions handle them. ...
user avatar
  • 143
0 votes
1 answer
57 views

How are discriminated unions (e.g. in TS) used in messaging schemes?

In the documentation about discriminated unions in typescript, here it says: Discriminated unions are useful for more than just talking about circles and squares. They’re good for representing any ...
user avatar
  • 127
0 votes
1 answer
114 views

How encrypting website data works

If i wanted to encrypt a password on my website before its sent to the server, would i have to encrypt the password in javascript on the frontend for it to be hidden over the interent or could it be ...
user avatar
2 votes
1 answer
312 views

When should a variable be declared / Value assigned?

So we have quiet a big TypeScript codebase at work, where each method resides in its own file. Now in a lot of those methods the variables are often declared all together at the top/beginnng of the ...
user avatar
5 votes
3 answers
417 views

Qualms over the 'flexibility' advantage of using dependency injection

I'm currently studying dependency injection and I'm having some issues with the so called 'flexibility' advantage of using dependency injection. The flexibility advantage is mentioned in post ...
user avatar
-2 votes
1 answer
98 views

How to warn devs after installing or updating npm packages? [closed]

I want to warn devs in my team to rebuild the docker containers after installing or updating npm packages. This is because whenever we edit packages in the environment the only way we've found to test ...
user avatar
  • 47
0 votes
1 answer
156 views

What is the use case of BroadcastChannel API?

I'm reading about BroadcastChannel API https://developer.mozilla.org/en-US/docs/Web/API/BroadcastChannel . It seems that it is already on market for a long time, and quite cool as well. However, what ...
user avatar
  • 129
2 votes
4 answers
582 views

Do all dynamically typed languages not support function overloading?

I have noticed that JavaScript and PHP and Python do not support function overloading. Do all dynamically typed languages not support function overloading? If the answer is yes, then why is that?
user avatar
  • 55
0 votes
2 answers
1k views

Defining default values for Boolean arguments in JavaScript

Is it usually recommended to define default values for Boolean arguments? I mean, is it usually recommended to define a function like this someFunction(a, b, x) { // a and b are strings, x is true ...
user avatar
  • 205
1 vote
2 answers
87 views

Using objects to construct nearly the same objects

I am getting worried I have some terrible design pattern here in JS/Node.js/MongoDB. It seems to that to create an object, I need an object that looks like that object. This includes data that comes ...
user avatar
2 votes
2 answers
681 views

JS - two array filters vs. one forEach?

I've had a question for a while. I know that the Array prototype method filter is generally preferred over forEach, and I believe it is typically faster at the job as well. But what about if I have ...
user avatar
0 votes
2 answers
53 views

Strategy for Chrome timing out on a Database cleanup job which takes a long time

I have a notifications app which sends users notifications. It uses a .NET core backend, an angular frontend and Cosmos DB. Within this I have an API endpoint function which is linked to a button used ...
user avatar
-3 votes
1 answer
134 views

Why isn't JavaScript always async? [duplicate]

In JS, code runs single-threaded, that's why asynchronicity is necessary. I cannot use code like result = someRequest(), instead I need to give it a callback someRequest(resultCallback) or write a ...
user avatar
  • 179
2 votes
4 answers
326 views

What would be a good analogy for explaining higher order functions?

I am teaching a beginners course on JavaScript programming and web development. Passing a function as a value into another function is a very common thing in JS from the very beginning. As the ...
user avatar
  • 447
-1 votes
1 answer
128 views

Allowing end users to upload a large amount of data using Excel

I've read Allow users upload CSV files, and embed the data for a simple API , Importing large data sets into a database over the web the closest concept is Is there a way to efficiently allow a user ...
user avatar
-2 votes
1 answer
138 views

Can I manage a NoSQL database with only JavaScript?

I am creating an app with Deno (a personal project), and I manage the "database" with only the Javascript code of the Deno enviroment, modifying JSON files like any other JS object. For me, ...
user avatar
  • 13
3 votes
1 answer
143 views

What is the role of ISO in the ECMAScript standardization process?

I've been told on StackOverflow this questions was off-topic so I'm asking here: From this webpage (ISO/IEC 22275:2018): This International Standard defines the ECMAScript Specification Suite ...
user avatar
  • 141
-2 votes
1 answer
104 views

Modify method behaviour at runtime

I have a scenario where user has multiple filters in a web application and a displayed list of items. In the gui it has multiple FilterGUI that he/she can tune interacting in the browser (these are ...
user avatar
  • 9
0 votes
1 answer
334 views

Web Components/Redux with .NET Core MVC viable?

I'm currenty building several new themes using NopCommerce, a .NET e-commerce platform using the MVC architecture. NopCommerce exposes a lot of services to you for communicating with the db, and is ...
user avatar
0 votes
0 answers
56 views

Best way to trigger javascript error to go to catch block

I have a couple of doubts regarding the quality of my code. I'm working on a helper function (for KoaJS) where I'm validating a Firebase ID token. If it is valid, I return the decoded token; otherwise ...
user avatar
34 votes
9 answers
10k views

Is it good practice to echo PHP code into inline JS?

I'm new to PHP and JS and I'm currently working on a gym management web app for our project in school. I'm adding a bit of QR functionality that sees if the user is eligible to enter the gym or not by ...
user avatar
2 votes
3 answers
262 views

White-Box vs Black-Box

I need some clarification on White-Box vs Black-Box testing. Is it correct that: White-box testing is testing your code that you are familiar with? Black-box testing is testing someone else's code you ...
user avatar
  • 137
0 votes
1 answer
78 views

Sending multiple calls from angular application

I am working in Angular project which is connected to REST API. Here we have an endpoint to create and update room types. POST endpoint for create and PUT endpoint for update exiting room types. Both ...
user avatar
  • 1
1 vote
0 answers
51 views

Securing Arbitrary Code

I need to run arbitrary code snippets in Python and Javascript on a server. It cannot be run in the browser. I'm thinking of sandboxing the code in an AWS Lambda serveless function. However, I'm ...
user avatar
1 vote
5 answers
2k views

What should the result be of a failing parseInt function?

When providing JavaScript's parseInt with a non-parsable string it returns NaN. I'm trying to understand the reasons for designing a parsing function this way. When I write a parsing function I ...
user avatar
-2 votes
1 answer
60 views

Authentication solution for custom PHP-based API

Here is description of my app I'm working on. On the client-side (index.html) a user can interact with a data. When he needs to call a server operation for example reading or writing a file on the ...
user avatar
  • 97
1 vote
0 answers
48 views

advice for web communication protocol for "streaming" multiple JSON objects to multiple clients

As a hobby / to learn I am building an app in JavaScript using Node.js where a component of it will take input from a client, send it to a server, and then broadcast it to other clients. For ...
user avatar
4 votes
2 answers
278 views

Arrays vs Maps for listing items that have a unique id

I've been finding that for a lot of code I've been writing recently, it naively might look like this: Array approach: const options = [ { id: 'red', label: 'Red', data: '#f00' ...
user avatar
  • 2,463
-1 votes
1 answer
85 views

How to record the sequence of events effectively when there is a logical flow runs over various event notifications?

Let me explain what I mean there is a logical flow runs over various event notifications based on our web app, which is event-driven and it is quite common in my opinion. User clicks a button to ...
user avatar
8 votes
1 answer
2k views

Is it bad practice to require the same module in multiple files in Javascript?

Let’s say I have three files, all of which import a fairly large module. But I’ve divided them because they have different functions. Now each of the JavaScript files needs an initial statement like ...
user avatar
2 votes
0 answers
69 views

I'm trying to write something that will fill out an Australia Post Declaration Form [closed]

I've got basic proficiency in PHP, JavaScript, html, and SQL. I also use Postman little a bit. I hope a solution to my problem can be found within those skills, but I'm willing to learn a new language ...
user avatar
0 votes
1 answer
124 views

Would an mutable to immutable transpiler be possible?

I'm very new to writing immutable code. Would there be any fundamental issues trying to transpile arbitrary mutable code person.age = 20 into immutable code person = { ...person, age: 21 }? I am aware ...
user avatar
  • 167
-5 votes
3 answers
2k views

How to unit test a public method that calls a private method [duplicate]

Here is a very basic example to illustrate my point class SomeClass { publicMethod1(param1, param2) { if (param1 === "some value") { // do stuff } else { ...
user avatar
  • 85
5 votes
1 answer
156 views

Clean way to handle different exceptions in Javascript?

I'm Java developer and I'm now learning Javascript creating a personal project. I don't know how to handle different errors in Javascript in a clean way and I can't find a good solution on the web. I'...
user avatar
0 votes
1 answer
72 views

Need help with React Shape building app architecture

I am trying to figure out how to build most scalable and maintainable architecture for my app. The app is just about choosing some shape and then editing it. More precisely, choosing some existing ...
user avatar
  • 111
0 votes
2 answers
63 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. ...
user avatar
  • 109
2 votes
0 answers
923 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, ...
user avatar
2 votes
3 answers
205 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 ...
user avatar
2 votes
2 answers
224 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 ...
user avatar
  • 129
0 votes
1 answer
83 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, ...
user avatar
-2 votes
1 answer
141 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-...
user avatar
  • 121
2 votes
1 answer
143 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 ...
user avatar
0 votes
1 answer
65 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 ...
user avatar
0 votes
0 answers
184 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/:...
user avatar
0 votes
2 answers
139 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 ...
user avatar
2 votes
1 answer
207 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 } } ...
user avatar

1
2
3 4 5
42