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
2 votes
1 answer
1k 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 ...
0 votes
0 answers
15 views

React function that opens and closes form in which user selects some data?

I am developing sales invoice form in ReactJS as SPA application, which communicates with API/DB (Laravel). I have the following use case: user clicks on one button (e.g. Select Person, Select Good); ...
0 votes
1 answer
184 views

Potential Solutions to loading Javascript classes unknown at run time

I'm looking for some advice or potential options for loading javascript files in real time long after the DOM has fully loaded. Those javascript files need to be sent over a WebSocket connection, and ...
0 votes
1 answer
315 views

How to avoid code duplication caused by javascript dict access?

I have two functions that group a list of dicts according to the value of a certain key. Here's how my array looks: const sections = [ { file_id: '1', heading_level: 4, readme_file_name:...
0 votes
3 answers
2k views

Is it still relevant to keep script tags in the footer?

Working at a company that loads all javascript at the end of the page load. This means I can't do $(document).ready() on my page, because jquery isn't loaded (the scripts are injected into the footer ...
0 votes
2 answers
424 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) => ...
0 votes
2 answers
7k views

What exactly is bootstrap admin-template and how it is supposed to be used

So this is my second ASP.NET MVC 4 project. It's decided that for this one we will use this template and it was said in a way that I felt really stupid for not knowing how exactly this template will ...
0 votes
1 answer
73 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 ...
1 vote
0 answers
634 views

How to design the state tree using redux?

In the last days I have searched for a documentation on how and when is it best to use redux and how to design the state tree. My research ended in the conclusion that there is no one correct answer. ...
1 vote
1 answer
84 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 ...
0 votes
1 answer
135 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 ...
23 votes
5 answers
15k views

Where should I do localization (server-side or client-side)?

I am currently developing a new web application based on a rich JavaScript client which communicates with multiple REST web services on my server. That application is intended to be used in at least ...
0 votes
1 answer
316 views

Javascript: Invest in ES6 or learn prototype fundamentals [closed]

As a budding software engineer, what is worth time-investment in terms of Javascript? I'm interested in long term payoffs in terms of a deeper understanding of languages, tech, software engineering, ...
0 votes
0 answers
51 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'...
3 votes
2 answers
3k views

Why are React keys limited to strings?

In React, when rendering a mapping from elements of a list/array/iterable to React elements, we're required to attach a locally-unique key to each element. Generally this is so that if an element ...
0 votes
0 answers
19 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(() => { ...
4 votes
1 answer
15k views

Why is it common to put an underscore before a method in JavaScript? [closed]

For example, I noticed that in the jQuery UI widget factory, methods like _init, _start, _on, ect.
3 votes
1 answer
699 views

DDD / Onion architecture in JavaScript

One reason I like .NET is because the 'solutions' and 'projects' lends themselves to good architecture. Good architecture makes it easy to follow the happy path of Domain-Driven Design. I've fallen ...
6 votes
2 answers
539 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 ...
0 votes
1 answer
78 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 ...
1 vote
1 answer
1k views

Angular2: Service architecture + error handling

I need support for Angular2 service architectures. I am quite familiar with Angular2 but I don't see the best way to implement services, error handling and their connection with the components. I'm ...
2 votes
2 answers
1k views

ModelState Validation vs JQuery vs Remote

I was stuck with some validations for quite a while. I have been thoroughly searching the internet to find ways to apply the validations I require. I came across many methods for validations even ...
0 votes
0 answers
42 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'], ...
2 votes
1 answer
302 views

Dynamic execution of Template Literals using a Map

I have a system that is generating internal events for objects. I am extending their debugger to display a human-readable version of the events sent to the debugger. For instance, the system will ...
1 vote
1 answer
388 views

Organizing reducers in Redux

I will use the following popular todo list example for demonstration. Let's say I wanted to create a very basic todo list with this structure as the app state: { todos: { todoKey1: { ...
4 votes
2 answers
2k views

Linking service and factory functions to controller $scopes in AngularJS

I'm trying to keep my controllers as thin as possible, so I keep my domain logic in services and factories. When I need to call a function in response to a user action like a click I assign the ...
2 votes
2 answers
408 views

How to get an object that another object is prototype of?

Javascript in the DOM has a peculiar characteristic. There's a different Object object that an object (by default) inherits per window. In order to find what kind of object is being sent to a function ...
0 votes
2 answers
121 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 ...
2 votes
2 answers
1k views

lambda function vs anonymous function vs callback function

I'm writing a introductory JavaScript tutorial series, I have a question about terminology. When explaining the Array.prototype methods, I've given an example of some code like: const letters = ['a', '...
0 votes
0 answers
32 views

Rule of thumb for responsibilities in Vue projects

I'm using Vue3 with the composition API and Pinia. I want to avoid tight coupling but sometimes I don't know the best place for the logic. To give you some examples, I'm choosing Minesweeper ( I hope ...
28 votes
3 answers
10k views

What functionality does WebStorm contain which RubyMine does not? [closed]

I am looking at buying Rubymine as I am doing a small amount of ruby, but a large amount of html5/javascript. I was going to get Webstorm as I do have a lot of pure html5/js based frameworks/apps ...
0 votes
3 answers
86 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: '...
0 votes
3 answers
424 views

Monads in JavaScript

A monad is an object that has: A transformation that takes a type and produces a new type. In C# we call such a transformation a "generic type". We have a generic type M<T>, we have a ...
4 votes
3 answers
2k 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 ...
-2 votes
1 answer
64 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&...
7 votes
4 answers
4k views

Managing JS and CSS for a static HTML web application

I'm working on a smallish web application that uses a little bit of static HTML and relies on JavaScript to load the application data as JSON and dynamically create the web page elements from that. ...
-1 votes
2 answers
144 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 ...
1 vote
2 answers
208 views

Should a client / server share error codes?

I am in two minds about sharing client / server errors codes. We are writing both ends of the system, if our API was external this would not be possible, but that requirement is very unlikely. So an ...
0 votes
2 answers
208 views

Sharing logic / services across modules in "clean" architecture [closed]

I am trying to implement a layered architecture consisting of; Controller, Service, Repository, Entity. Each module has at least some of the above layers. I am often finding that modules need to share ...
0 votes
0 answers
32 views

Managing user session state with Google Sign In

I need some help with my authentication design. Happy to share any code as needed... Overview I have implemented the Google Sign-in (new web implementation here) button in my client web application. ...
0 votes
1 answer
47 views

NextJs Explanation on Ecommerce and Other Project Implementation [closed]

I'm attempting to create a project to increase and enhance my coding skills, and I've lately migrated React to Nextjs. I've noticed that NextJs' main point or strength is rendering; Could someone ...
-1 votes
1 answer
172 views

How to use external validation libraries for entities in a "clean" architecture?

I would like to make use of a external library to parse the core domain entities. Doing this in a naive way it would look like the following: import { z } from 'zod'; const Audience = z.object({ ...
1 vote
1 answer
98 views

How do I share translations between a .NET application and a react application?

I currently have two applications where one is a landing page (built in react) and another is a web page that lets users explore data (Written in ASP.NET 4.7). I'm currently using resx files to handle ...
0 votes
1 answer
89 views

Javascript and payment security

I'm using a third party CRM application which allows you to build web forms using drag and drop widgets and the ability to add javascript code to manipulate those widgets. I need to build a form to ...
49 votes
3 answers
14k views

Why does Javascript treat days and months differently?

I've noticed that in JavaScript, when creating a Date, months are zero based, and days aren't. For example: var foo = new Date(2012, 1, 1) produces February 1st 2012 Why is this?
13 votes
1 answer
1k views

Order and filter Server-Sent-Events in angular.js eventsource

I have a Client in AngularJS where I consume multiple SSE (Server-Sent-Events) in Java from the Server Side (there are multiple endpoints in different web servers in the backend). Diagram link I ...
4 votes
1 answer
2k views

Collecting user input to use as query with API

I'm attempting to collect the user's input and execute a search using an API. At this point, I can use the API (ebay search) by typing keywords into the html document- but I want the user to be able ...
40 votes
6 answers
12k views

In JavaScript, how is awaiting the result of an async different than sync calls?

I'm having a hard time wrapping my head around the use of async/await and regular sync function calls in JavaScript. Let's say I have two functions: Function 1: async function doSomething() { ...
1 vote
2 answers
124 views

How to create an API on Node.js that needs to be updated once a day?

I want to create an api based on Node.js and Express.js. This api should return an array of products on /products. To get these products on my node server, I need to call a third party api. However, I ...
70 votes
3 answers
314k views

How do I make a JavaScript promise return something other than a promise?

I have a spec from a client for an implementation of a method in a module: // getGenres(): // Returns a promise. When it resolves, it returns an array. If given an array of genres, ['comedy', '...

1
2 3 4 5
42