Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

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.

-3
votes
0answers
17 views

How to design/architect a double navbar interface using Native JS [on hold]

A design pattern that I admired is a left side double navbar. When you click on a button on the left, it has two functions. The first is it controls the second navbar section which when clicked, ...
-3
votes
0answers
22 views

What are the requirements and use cases on doing a Front End Technical Architecture? [on hold]

I'm basically new to creating architectural stuffs and I'm now asked to create a "Technical Front End Architecture", but my understanding for that term is that I need to list all the tools that I'm ...
7
votes
6answers
3k views

Why do programming languages not let you use a try block without a catch block? [on hold]

Why do languages demand catch blocks when they aren't needed? The compiler or parser complains with this code: try { const utils = require("applicationutils"); } But it is OK with this code: ...
1
vote
1answer
50 views

Is it normal approch get all items after post new item?

Problem description: Parent view displays a list of items. This view has button add a new item to list wich open modal for creating a new item. Two approaches how to do that: 1) POST Request -> ...
0
votes
0answers
45 views

Handling user permissions in front-end

I'm building an API that will be used by the front-end in React and I'm not quite sure how I should send the permissions of each user based on their roles. Some fields can only be edited in some ...
0
votes
1answer
51 views

JS Higher Order Function is even necessary in this scenario?

In Javascript, I have seen a code like: const getSomeMapper = (param1, param2, param3) (param4, param5, param6) => { // uses all these params and returns a promise } interface ...
0
votes
0answers
59 views

Should modules strive to export only one thing?

Ideally, functions should do one thing well, and only one thing. Does the same thing apply to what a module should export? Of course, modules aren't always the same thing as functions, but they often ...
-2
votes
1answer
123 views

Is there a way to recreate the code behind the for loop?

My question is, how would I go about making a function that serves the same purpose of the for loop, without using any loop method. function fl (initial, condition, iterator, code){ i = initial; ...
0
votes
0answers
46 views

Why does Babel convert async/await to generator functions rather than promises?

It's a bit of a moot point now that async/await is supported by all major, modern JavaScript engines, but I've always wondered why Babel converts async functions to generator functions rather than to ...
0
votes
2answers
110 views

Card game with unique abilities - how do i implement this

I am making a card game, it is similar to Bang. You have a boss, which has some HP and you are getting cards with abilities, HP,DMG, etc. I want to make it as a .io game or maybe just a web ...
0
votes
0answers
27 views

Why does Vue.js rename / move all the internal data elements?

I'm following the code from Vue.js in Action, Chapter 3. (much deleted for brevity...) var webstore = new Vue({ el: '#app', data: { sitename: "Vue.js Pet Depot", showProduct: true, ...
0
votes
1answer
55 views

How to organize work with a few projects with shared codebase?

We develop two projects (and more in future) with JS, Vue.js, using npm, and we store each project in its own git-repository. We want to place common components (buttons, page-parts and page ...
0
votes
1answer
70 views

Is JavaScript added and executed in rendering or parsing?

AFAIK, each web page is created in a two stage process: Parsing and rendering. In parsing, markup (Say HTML) is taken as is, or created from a server-side programming language like PHP, In the ...
1
vote
1answer
109 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 ...
1
vote
0answers
109 views

are magic strings as event names okay

I am about to create my own event-driven API in JavaScript. Most JavaScript that currently exists, e.g. in-browser JS for controlling the DOM, lets you register event handlers like this: object.on('...
1
vote
1answer
24 views

Form validation or model based verification on client side

I'm actually wondering what are the pros and cons of these two ways to handle client side validations / verifications. Let's imagine an application where there is a contact form that needs these ...
1
vote
0answers
40 views

What is a message in relation to javascript's message queue in its event loop?

I'm learning about javascript's event loop, however I'm not understanding what a message is? The resources I find mention how the callback associated with events get added to the message queue, but ...
-1
votes
3answers
162 views

Why are framework javascripts not reutilised between pages?

As some js files are very common and widely used on the web, why browsers don't reutilise them? wouldn't it improve efficiency, as js framework files are usually heavy?
1
vote
1answer
69 views

Download file stream as it's being generated

Scenario We are building a UI that allows users to query our data in bulk. The return format is CSV and there is a decent amount of processing that needs to happen, so this processing processing is ...
2
votes
1answer
51 views

Design Pattern to implement a settable JavaScript Module variable

I am writing a client to talk to a server API in JavaScript. I have an OOP background but am trying to embrace modern EcmaScript. So I started with this: customerApi.js: const baseUrl = "http://...
2
votes
2answers
80 views

API Race conditions

I have an API in which we expect a emailID and a certain deal data. The case is we want to keep the dealId and contactId(email) to be unique. Creating a deal requires data insertion in multiple ...
0
votes
0answers
57 views

Allowing a user on one page to be able to cause an event on another

I would like to allow a set of users to be able to submit a form on one page, and then it would cause an event to trigger on another page. For example: Submit Page: Includes the form, the user ...
-1
votes
1answer
75 views

Is it a bad idea to persist a javascript function?

I'm working on eventual consistency. In short I have a bunch of promises and I want to make sure they get retried until they succeed. It would make my life a lot easier if I could just persist the ...
-3
votes
1answer
62 views

How compiler and interpreter both are used in one language? [closed]

After writing the complete code the compiler compile the whole code at a time , but on the other hand interpreter take single line at a time. Both the compiler and interpreter are mostly called the ...
1
vote
2answers
102 views

How to write unit tests a method with a result that is highly based on another method [duplicate]

How to write unit tests a method with a result that is highly based on another method ? async function getStatus( session, correlationId, data ) { const client = new SomeAPIWrapperClient({ ...
2
votes
1answer
25 views

handle file downloads from the server

I am wondering if the following would be a good technique to allow user to download files from the server in the below scenario: Info about the scenario: User logs into a system (HTML,JQuery and CSS,...
1
vote
1answer
61 views

ES6 - Where is it better to initialize a member - parent class or derived class?

I am trying to figure out if there is a better practice for initializing class members of derived classes in ES6 - in the child or the parent, and why? For example: Option 1: class AbstractAnimal {...
2
votes
1answer
190 views

Which programming pattern is best for checking which partition a number lies in?

I have an interval partitioned into “MECE” subintervals, and I want to check which subinterval a number lies in. (MECE stands for “mutually exclusive & collectively exhaustive”, meaning the ...
1
vote
1answer
107 views

Should a function implementer or function caller handle immutability

I know there is no right and wrong answer here, I'm just looking for other opinions on who should handle immutability, dependency inversion and decoupling. Example 1: Here each function caller has ...
0
votes
2answers
77 views

Website Multi Languuage [closed]

I have one website and the website are now in HTML, that actually is structured: domain.com = English domain.com/es = Spanish domain.com/de = Germany I copied the HTML of English page to Spanish ...
1
vote
1answer
69 views

How function parameters are compiled in JavaScript

I am trying to understand how functions -- which could have dozens of parameters that could themselves be functions or complex objects (I'm thinking JavaScript) -- get passed the arguments when ...
2
votes
0answers
31 views

Dynamic API Data Validation

I am in the process of building an heavily data-driven web application written in Node.js / Typescript with Mariadb for the database engine. I am trying to put an emphasis on extensibility and DRY ...
1
vote
2answers
307 views

Avoid if-else block in favor of default assignment followed by if

A colleague, and frankly better software engineer that me, is telling me that this pattern let variable = someDefaultVariable(); if (some_boolean) { variable = someOtherValue(); } is better than ...
3
votes
7answers
884 views

Why don't languages use the words “and” and “or” instead of “&&” and “||”?

When I was a beginner it took a while to learn the language syntax and the idea that languages couldn't improve after they were invented. But now we're seeing new language features added every year ...
1
vote
0answers
38 views

Best practices for positioning elements in an HTML-based game

It seems like HTML5 has about a zillion different layouts and methods for positioning divs, few of which seem to work exactly as described in most browsers. Imagine an implementation of, say, Tetris ...
1
vote
4answers
94 views

filter + map api design

I am writing a library call that will allow you to filter and map in the same iteration of the loop, this is async/callback style in Java. The problem of course is that for filtering we usually return ...
-1
votes
1answer
72 views

RPC with Express JS? [closed]

I've been working on a project recently where I have an Expressjs server that supplies weather forecast data to its clients. Right now, I'm using express simply as a means of exposing some functions I ...
1
vote
4answers
267 views

Writing C# utility that checks on property

I have a business requirement that requires checking on a person's first name to ensure it does not have the character "1". The model: public class Person { public string FirstName { get; set;...
1
vote
1answer
48 views

Efficient and readable method for styling of javascript webcomponents

I have a web page that loads a very long list of custom web components, each with their own shadow DOM and a stylesheet shared by all instances. Originally, I included the stylesheet as css file ...
-1
votes
1answer
123 views

Does avoiding Promises and Async leads to clean code?

While applying for a job interview I found this line in requirements. Experience with clean code writing practices like avoiding callback hell like promises, async Does this line make any sense ? ...
0
votes
0answers
27 views

Messaging engine architecture with front-end and ORM layer (spring)

I'm looking to push my first QuickFixJ messaging engine into production, and I would like to know the best way to do so. Bear with me. The gist of the responsibilities is as follows: Through ...
1
vote
2answers
157 views

Is it bad practice to leave hidden elements in the dom?

I'm looking for perspectives from other web/ui developers. I'm a UI developer and my company requires that I use components built by another team within the company. That team has developed some ...
0
votes
3answers
148 views

If callback function, promises and async/await patterns all can be used to achieve asynchronous behaviour then why don't we stick to one?

As far as I have seen then async/await, callbacks and promises are and can only be used to achieve asynchronous programming. Correct? So my questions are: 1) Is it correct that the former three is ...
2
votes
0answers
103 views

What is the state of immutability in Javascript in 2019?

I'm all on board with functional programming in Javascript - particularly within the context of using React and Redux. Something that I've been running into again and again, is how easy it is to ...
0
votes
0answers
32 views

Extending prototype

I am currently refactoring a project where I come across the following kind of code multiple times: propertyFunction: function (feature) { doSomethingOnyWithFeature(feature); ... } Methods, that ...
0
votes
1answer
118 views

Difference between a strongly typed language and a weakly typed language with type annotations from the developer's point of view?

I understand that there are major technical differences between how a strongly typed language is compiled and how a type annotated language is compiled/transpiled. But as a developer writing in a ...
0
votes
1answer
111 views

What is the original reason JSON used `null` and not `undefined` to represent missing values?

In Javascript, there seems to be or have been an idea that undefined represents a missing primitive OR object value, while null represents just a missing object value. See, for example, this section ...
0
votes
0answers
53 views

Two Web clients and Java server (HTTP and Websockets)

I have 3 software components of a Web Application: 1. JS-client application 1 (JSApp1) 2. Java Spring (REST and Websockets) server app (SRV) 3. JS-client application 2 (JSApp2) My current task is to ...
0
votes
1answer
57 views

Adding custom properties to Javascript Objects of external libraries - is that considered bad practice?

I regularily come across code that stores some custom properties in JS Objects from external libraries, for example: /**@param OpenLayers.Feature feature */ function doSomething(feature) { ...
1
vote
1answer
21 views

Geolocation client side requests: Key and ID storage

I'm developing a small web-app to help users manage shopping lists. One of the required features is the ability of the application to notify the user if a shop of the same category is near him/her. ...