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.

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

Interruptable/resumable sequence of actions in client-server game

I'm implementing an online turn-based game, where game state changes are driven by client actions sent to the server. Valid client actions are generated and validated by a values method, which takes ...
0
votes
1answer
195 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: { ...
-1
votes
1answer
156 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 ...
-3
votes
1answer
63 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
536 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
84 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
218 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
355 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
113 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
70 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
0answers
63 views

Designing currency exchange class

I am writing a small library to get the currency exchange rate, at present the data is being gathered from European Central Bank which provides exchange rates from EUR. The rates are updated daily ...
0
votes
1answer
732 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 ...
-5
votes
5answers
250 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 ...
0
votes
1answer
188 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 ...
0
votes
1answer
177 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 ...
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 ...
1
vote
1answer
422 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 ...
0
votes
1answer
116 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
75 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 ...
1
vote
2answers
163 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 ...
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 ...
1
vote
0answers
99 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', ...
4
votes
2answers
486 views

Benefits of using a JS Framework

I am starting a new project and trying to decide if I should use a Javascript framework (like vue.js or react) and create a Ruby on Rails API, or use Ruby on Rails to server-side render pages and ...
0
votes
1answer
210 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
113 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
109 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 ...
8
votes
3answers
571 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. ...
7
votes
4answers
965 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
106 views

Serialized Object Representation in Javascript from PHP

Let's say I have a Widget object that I serialize and send back to the browser at a regular interval. This Widget object includes lots of different members (variables) and other objects along with ...
0
votes
1answer
58 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 ...
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. ...
0
votes
1answer
68 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 ...
0
votes
1answer
134 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 ...
0
votes
1answer
101 views

What would be more efficient, move DOM elements or clone them?

I have this dilemma, I have to make a menu, the basic estructure is four to six main menu items and each one can have N level 2 menus and each sub menu can also have subs. I get from the server this ...
1
vote
0answers
122 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 ...
3
votes
1answer
141 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....
0
votes
2answers
87 views

How should I dynamically retrieve data depending on the size of the user's browser window?

I'm developing a chat module for my employer, and one of the requirements is that I "get enough backlog to fill the screen" when opening the room, instead of always limiting it to a specific number ...
-4
votes
1answer
89 views

What is the truh concerning pasting data into a browser? [closed]

I am hearing a ton of different info. I just found this in a site The 'paste' operation in the context menu or button press is not possible. It is not possible because of a browser security ...
0
votes
2answers
55 views

How inject a collaborator who needs a back reference into a constructor

Following Hevery's advice to inject collaborators into constructor rather than new'ing things within constructor body, how gracefully do this when a collaborator needs a back reference to its owner, ...
1
vote
0answers
169 views

Front-end-side encryption: Where to store password throughout session?

currently we're working on a small application where we store a bunch of JSON data coming from a JS-based graphing editor (think of a spiced-up version of this) in a Rails-based backend. We want to ...
1
vote
1answer
1k views

Is it a good practice to log client side errors to a file

I basically want to know if it is considered a good practice to persist the errors that happen on the client side of a web application (typescript/angular for example) by logging them to files? Or if ...
3
votes
1answer
57 views

Realtime Live Auto updates for web applications

It's about trying to understand the architecture behind how updates to web application is done. I've been working on a non-public website that has bunch of records displayed in a UI, now the ...
1
vote
1answer
2k views

element.style.setProperty(property, value) vs element.style.property = value [closed]

I was wondering if I should use element.style.setProperty(property, value) or element.style.property = value. I am very much tempted to start using element.style.setProperty(property, value). But in ...
0
votes
1answer
1k views

Should I generate GUID/UUID on client or server?

I want to generate a GUID/UUID for my web app to use but I'm not sure if I should generate it on the client or server or what should be the preference. Basically, I'm working on a web app similar to ...
1
vote
2answers
948 views

Best Practices - Including endpoint URL calls in JavaScript vs backend calls

I am building a web application that will retrieve results from a remote server and use them to render some charts and maps. The remote server has already been implemented and contains a large amount ...
2
votes
1answer
190 views

Is it a best practice to use a mocking service for testing http requests?

Is it better to unit test using a mock library like 'nock' (nodejs) or to just test the server's http requests directly? Here is an example of my Express server test for testing if my server is up ...
1
vote
0answers
107 views

ES6(babel): Best practice for create class

I have a Product class. When I attempt to reference this from within a method on the class, I get an error saying this is undefined. To solve this, I have to bind this to all methods. And this, for ...
0
votes
3answers
240 views

Which is more readable: early returns, or conditionals? [duplicate]

I’m writing an asynchronous, Promise-returning function. In the processing I test some conditions, and if the conditions pass, the promise should be fulfilled (resolved), but if one fails, then the ...
0
votes
1answer
566 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 ...