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
vote
2answers
201 views

Declaring a function without named parameters that accepts at least 1 argument

Say I have a function whose first parameter is used differently depending on how many arguments are passed. In this case, it is easier to just process the arguments object as a whole within the ...
0
votes
1answer
226 views

Class definitions in static getter methods

[Node.js / CommonJS] I'm creating a single GitHub repo for my tool which has a Core, Control, Server, and Client library. It's unlikely that all of them will be used at the same time. I'd like my ...
1
vote
1answer
751 views

google maps API key for clients

Google API key is now required for new websites even for a single map embed. How are you going to handle this? I guess the correct way should be to ask a client to create his google API key and send ...
2
votes
1answer
93 views

What is the advantage of flattening dependent Promises

I've read that nesting Promise continuations is bad practice. For example, here. GetCustomer().then(customer => { ProcessCustomer(customer).then(processingResult => { console....
2
votes
1answer
437 views

Best practices for calling multiple APIs and manipulating data before showing it to user?

I am building a web application that makes use of multiple API's (Google Maps, Weather APIs, and more). I am using Python + Flask on the backend, and Javascript (probably with React, I have not ...
1
vote
1answer
41 views

JavaScript/NodeJS Class Extension vs Adding Properties

I am currently writing a Discord bot and have reached the point of needing a refactor. With this being my first stab at JavaScript/NodeJS and making a bot in general, there are a lot of mistakes I ...
0
votes
1answer
56 views

Privacy in prototypal inheritance

People say that everything in The prototypal inheritance is public But we can achieve privacy using closures in the constructor right? function Cons(id){ this.name='Hermit'; this.check=function(){ ...
0
votes
1answer
162 views

Architectural Problem in use of ToneJS with Vuex

I'm using the Tone.js library to build a (music) sequencer in Vue+Vuex, and have encountered this problem: Individual music tracks of the sequencer are created dynamically, so I'm storing objects ...
108
votes
3answers
36k views

Benefits of Structured Logging vs basic logging

We're building a new app and I'd like to include structured logging. My ideal setup would be something like Serilog for our C# code, and Bunyan for our JS. These would feed into fluentd and then could ...
-1
votes
1answer
161 views

Is it bad practice for a composited instance to reference its parent? If yes, why?

I'm building a Selection class that holds and allows manipulating selected Items on a canvas. The Selection is part of the Document, the top-level app-container if you will. I'd like to be able to ...
-5
votes
5answers
254 views

I learnt a languge suppose (Java). I also know python. I want to write a simple app. Is there any way to run both language same Time?

I had been learning python and i know Java. if i were to write a simple program, can i write both programming language in one document or compiler? I got into this problem because if i cannot merge ...
3
votes
1answer
579 views

What is a (Redux) selector?

I am learning Redux (a JavaScript state container tool). I am finding numerous references to something called a "selector" (e.g. here, here, here, and here). However, I don't seem to be finding a ...
-3
votes
1answer
66 views

Creating a multiplatform (IOS, Javascript, and JAVA) linked user account database

I have done weeks researching this question for my App Idea. Background of the APP - Simply a multi crypto currency wallet which users sign up with ONLY username and Password - no email, FB, or ...
-1
votes
2answers
600 views

How does a dynamic array access work?

In C if i declare int x[4] Which tells me its an integer array with each array element size fixed of size 4. So after initialization when I access x[3] : address of array +element size which is 2 *...
-1
votes
1answer
85 views

How to develop larger client-site in-browser apps in javascript?

I'm new to javascript environment (I have background in C++ physical simulations and game engines). With rise of HTML5 and WebGL I was thinking I'd like to try make some games/3D editors using ...
0
votes
3answers
223 views

less functions and complex code or more functions and readable code?

I am currently making an html-based editor, i know there are lots of editors out there especially html based but i want to do it myself once. What i am concerned about is, for e.g, when a user press a ...
1
vote
0answers
376 views

Should Flux mutation logic always be done in the store, or can it be delegated to a class?

(I am using Vuex but the question applies to any Flux architecture.) I don't have a great understanding of the reasoning behind Flux architecture. I understand that it is nice to have all of the ...
1
vote
1answer
115 views

How to handle dependency between two unrelated objects?

I am trying to figure out a way to solve the following dependency problem. I have a parent object DomManager that has the responsibility to handle all the interaction with the DOM. It initializes ...
0
votes
2answers
71 views

I have two different account types that can do different things in a Single Page Application. Should I turn it into a Multiple Page Application?

In my new SPA (Single Page Application), I have teachers, which can make tests, and students, which can take tests, subscribe to teachers, and view their grades. This means that in JavaScript, they ...
0
votes
1answer
863 views

How to impersonate user in web app?

I am building an intranet web app with ASP.NET. We are using Windows authentication for granting access to different web pages. We grab your Windows login server side, then build web pages ...
3
votes
1answer
142 views

What is the standard method of handling errors in a NodeJS web app?

I am currently working on a web application as a learning project, which has a NodeJS backend and uses a MongoDB database; however, I believe my question is not specific to the technologies I am using....
2
votes
1answer
119 views

How do I differentiate between old and new data in backbone collections?

A common pattern I come across is a backbone collection which is initially seeded from a database. However, the user can also add to the collection. When the user does add to the collection, these ...
0
votes
1answer
222 views

Why “typeof null == object” will stay in javascript?

I was reading a article about front-end development on Medium, when I stumbled upon an interesting piece of information, which is as follows: The type of a variable can be determined by using the ...
1
vote
1answer
512 views

Chat application - write to file and then save in database

I have followed this approach that is described here to implement a simple chat application: https://code.tutsplus.com/tutorials/how-to-create-a-simple-web-based-chat-application--net-5931 I'm ...
2
votes
1answer
81 views

Are there standards for handling card swipers in applications?

I'm in the middle of creating a web application for a client, and he wants me to integrate magnetic card swipers so his office staff can quickly swipe a card, and load up details for specific patients ...
0
votes
1answer
142 views

Why the methods of the Object Constructor do not work on DOM Elements

//------------ let person = { name: 'John Doe', age: 22 } let e = document.getElementById('task-title'); /* Object.getOwnPropertyNames() Returns an array containing the names of all of the ...
1
vote
1answer
77 views

How to make a secure web-app account system?

i have some experience (mostly as a student) with react and redux, and on the other hand i also have some experience with express, normally for my apps (all of them are really simple) i make a rest ...
16
votes
4answers
1k views

Unable to solve mystery of functions in Javascript

I am trying to understand behind the curtain scenes of Javascript and kind of stuck in understanding the creation of built in objects, specially Object and Function and the relation between them. ...
1
vote
2answers
171 views

HTML and JS code structure

I am relatively new to HTML/JS and am very much an amateur programmer. I have created a web app that works but I can't help but feel that the code is a spaghetti mess! I have been looking for JS/HTML ...
8
votes
3answers
624 views

Communication between decoupled components using events

We've got a Web App where we have a lot (>50) of little WebComponents that interact with each other. To keep everything decoupled, we have as a rule that no component can directly reference another. ...
1
vote
0answers
58 views

Is this a good solution for Card holder applications?

Business case I am currently looking for a better architecture to replace the current implementation for my application. Currently, My application runs on a mainframe system with CICS used for ...
29
votes
2answers
117k 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
vote
0answers
101 views

If you name the functions on a “factory class” and then invoke them statically, is still a factory?

Let's take the following Javascript, but the language is not really relevant: module.exports = (user) => { return { createPrimaryConfig: () => { return new Config('a', 'b', ...
6
votes
4answers
1k views

Best way to do Client side authorization for a single page JavaScript application?

I already have a solid back-end permissions authorization (ie. admin can perform an action, a normal user cannot perform an action). However, I'm wondering if there is a better way to do a frontend ...
0
votes
1answer
228 views

JS Captcha in contact form validation to avoid spam bots

I am looking for opinions about how bulletproof could be this captcha system to avoid spam in a contact form. The form submit goes through ajax. So I generate 2 random numbers with javascript. The ...
2
votes
2answers
115 views

Better method to adding lots of options in a function

I have a JS function that takes JSON data and creates an HTML table. As my project developed, I needed one specific table to be created with a button - so I added an option to the function and an ...
1
vote
0answers
118 views

Design differences in Angular UI components and regular JS UI components [closed]

I'm an experienced JS developer and I've been involved in front-end development for multiple web applications. I've developed a couple of custom JS components to suit the project. I'm currently tasked ...
0
votes
1answer
73 views

Is creating near duplicate partial views solely for populating html elements with Ajax returns violating DRY?

Maybe anti-pattern is a better word for this question. I do not know, but I mean a violation of DRY. Id like to reuse a partial view, and I can, but that partial view has other things in it I don't ...
3
votes
2answers
529 views

REST Api Design Patterns

I'm developing a REST Api using Node.js & Express.js. Recently I've started looking towards best practices for REST Api design but it's bit confusing so please bear with me. For Example: Lets ...
3
votes
2answers
523 views

Mixing JavaScript and server-side scripting

I see code like this sometimes (mixed PHP and JS in this case, but could be any server-side language): <script> var data = <?php echo $bigDataStructure ?>; // then lots more pure js ...
0
votes
1answer
78 views

Ext JS: Designing a base class and override it

I'm trying to define a base class and override it's items on different inherited sub-classes. I'm following MVVM pattern to fetch records from backend. Created several stores and formulas within ...
27
votes
3answers
19k views

Dealing with browser cache in single-page apps

I'm trying to figure out how to properly handle the web browser cache for single page apps. I have a fairly typical design: several HTML, JS and CSS files implementing the SPA, and a bunch of JSON ...
2
votes
1answer
307 views

Javascript / Ecmascript language grammar disambiguation

I'm working on the design of a compiler for a language in which I have to use curly brace for two different purposes. I am currently stuck in writing a non-ambiguous grammar but I realized that some ...
0
votes
1answer
632 views

Is it okay to use var on purpose in ES6, as opposed to let?

I was really glad that ES6 introduced the let keyword for defining variables. var scoping rules can lead to all kinds of issues, especially when working with loops and event handlers. Even when ...
2
votes
1answer
512 views

Could it be possible to add the integer type to the ECMAScript standard?

In JavaScript, every number you will ever use will always be represented with what C programmer would call a double. The official type is I believe number. If I recall correctly, that fact was ...
-1
votes
1answer
281 views

Strategy To Upgrade Frontend Javascript Code - Typescript or New Framework?

Here is my scenario. I would like advice on which path to follow, along with good reasons as to why. It would even be better if you could give an example based on experience of a similar decision but ...
2
votes
1answer
772 views

Is there a way to use html5 custom elements without javascript?

I know requiring javascript on a webpage has been a hot topic the last couple years. I'm wondering if someone wanted to use custom elements but still allow the website to be usable without ...
3
votes
5answers
14k views

Javascript - Avoiding variable redundancy in nested for loops

Please bear with me, I could only explain the problem in the comments of the code snippet below. Please read through them carefully. Question at the end: I usually tend to name the variables used in ...
1
vote
0answers
145 views

Understanding transducers, why this is not a transducer

I'm currently learning functional programming and trying to learn a new concept : transducers. I'm actually getting the point of theory, like it's an advanced map/reduce that aims to provide better ...
59
votes
8answers
54k views

Why do people disable JavaScript?

I asked a question yesterday Should I Bother to Develop For JavaScript Disabled?. I think the consencus is: Yes, I should develop for JavaScript Disabled. Now I just want to understand why users ...