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.

4
votes
0answers
282 views

Should an SPA use OIDC's Implicit flow or Auth Code flow?

We are developing a new Angular SPA which leverages Keycloak for its SSO abilities using OpenID Connect (OIDC). The app is currently designed to use the Implicit flow to retrieve short-lived access ...
2
votes
0answers
34 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 ...
2
votes
0answers
111 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 ...
2
votes
0answers
66 views

Is there a recommended design/architecture when developing a JavaScript module?

Practicing some of the ES7 features, I started developing a class to perform some actions on the DOM and use the new features. I used Babel to make it work on the browser, and the code looks something ...
2
votes
0answers
124 views

Is there an accepted Coding Style for multiple ES6 Arrow Functions?

I'm starting to use ES6 arrow functions more, but haven't found a coding style that I like, especially when chaining them together. e.g., Eric Elliott gives this code: mix = (...fns) => x => ...
2
votes
0answers
220 views

Redux Saga pattern for large, non-specific server responses

Our current Redux state tree is this: { "dog": { "name": "Barkley", "age": 6, "hungry": false, "location": "Living Room", "height": "36 in." }, "...
2
votes
0answers
238 views

Does using returnTrue() or returnFalse() functions a code-smell?

I was trying to understand how jQuery's cross-browser events work, when I noticed these two functions in the source code: function returnTrue() { return true; } function returnFalse() { ...
2
votes
0answers
779 views

Drag and Drop with animations

This is more of a theoretical question which I hope is okay!? I want to code my own drag and drop jQuery plugin, but i'm wondering the best way to go about structuring my code and actually doing it. ...
2
votes
0answers
100 views

In browser form validation in laravel

In laravel 5 I describe models without specifying fields in model class. Some magic identifies which fields exist in database for this model. use Illuminate\Database\Eloquent\Model; class MyModel ...
2
votes
0answers
984 views

How to passing variables from php to react.js component?

For example, I have a react.js component named Question which need the props title,id,content. <div id="main-section"> <div id="question"></div> </div> ReactDOM.render( ...
2
votes
0answers
79 views

How to architect rule matching with multiple conditionals and outcomes

I'm working on allowing my users to create their own ruleset for data that's coming in. All of the data below is sample mock data and not in relation to our product. Example of a rule (there can be ...
2
votes
0answers
173 views

Javascript: How to get the Object an 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 ...
2
votes
0answers
88 views

Suggestions for Storing large collection of related words

I am trying to create a simple sentence generator that uses templates and a database of words. It will be a website where essentially a user could click a button to generate a sentence. For example: ...
2
votes
0answers
263 views

Hot swapping files and metaprogramming with front-end JavaScript

I was inspired by a video on hotswapping JS files with React + Webpack for the web. I started trying it out with React + Backbone + RequireJS. Seems to work, as long as I stick to the stateless parts ...
2
votes
0answers
445 views

JavaScript program design: to what degree should I separate logic and display?

Consider you wanting to implement a simple game of checkers. There would be a rectangular game board and the player would able to move the pieces around according to a particular set of rules. ...
2
votes
0answers
1k views

Managing Login Authentication/Webpage session: Can client side javascript/JQuery access either a session variable or json variable in html?

Short version: A variable is stored in a session variable req.session.userName and also in the json sent with res.render('/', {username: value}). How can I access either of those variables from inside ...
2
votes
0answers
124 views

Can/should objects share methods in certain circumstances?

I am currently working on a web application that is supposed to resemble an operating system with GUI (it manages processes and windows). I have several constructors which deal with different aspects ...
2
votes
0answers
482 views

How can I put multiple hierarchical forms in a single web page and avoid making it a mess?

We are a group of developers working on a web application that accepts forms filled and sent by our users and present it in an overall view. Our main form view looks like this: There are multiple ...
2
votes
0answers
376 views

JS closures - Passing a function to a child, how should the shared object be accessed

I have a design and am wondering what the appropriate way to access variables is. I'll demonstrate with this example since I can't seem to describe it better than the title. Term is an object ...
2
votes
0answers
481 views

Should we still care about _escaped_fragment_ and alternate HTML generation for Single Page Applications?

A few months ago I started a project, which will have two parts – business client overview panel (AngularJS SPA) and public front-end (dynamic HTML with progressive enchancements via XHR). I'd really ...
2
votes
0answers
446 views

Should I use SignalR to synchronize & cache CRUD data to a mobile app?

I'm considering using SignalR to send data to a mobile app, but need to have a way to synchronize data while it's closed or pending updates. Is it a good idea to use Backbone.js <--> SignalR to ...
2
votes
0answers
464 views

Reducing code complexity for an interface between angular and d3

I'm playing around with different ways of integrating d3 and angular, in the context of learning both of these frameworks, and am hoping for some input: My client application receives a JSON array ...
2
votes
0answers
135 views

Reasoning behind indexedDB versioning

So, the last 2 weeks I have been fighting with indexedDB and one of two recurring questions that keep popping up is why indexedDB has to use/present it's entire versioning system? I do understand that ...
1
vote
0answers
131 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
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
0answers
89 views

Refactor MVC to more scalable architecture?

Months ago I began a new web project which, in the beggining, seemed like a small application with virtually few users. I began the project by using the awesome Hackathon Starter WebApp Boilerplate by ...
1
vote
0answers
373 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
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
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', ...
1
vote
0answers
140 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 ...
1
vote
0answers
238 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
0answers
110 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 ...
1
vote
0answers
43 views

Exporting functions usable by both client-side and server-side

So this isn't a question on how to do it, but more of a clarification on how it works. I'm using Vue and I'm creating a file that's usable by on both the client side and the server side (logic should ...
1
vote
0answers
1k views

What are the best practices for picking selectors for web scrappers?

The following is an example using https://github.com/GoogleChrome/puppeteer 'use strict'; const puppeteer = require('puppeteer'); (async() => { // const browser = await puppeteer.launch(); // ...
1
vote
0answers
392 views

Pre-rendering a lot of images in HTML5 canvas, good idea?

A lot of things on the internet are very conflicting on how to deal with things. Here's my situation: I'll be building a client in javascript, using the HTML5 canvas, the canvas will contain ...
1
vote
0answers
47 views

How do I protect JS local scope but allow outside customization?

I am creating a javascript application that will live in a library and be used on multiple sites. I am looking for it to have the following features and need some guidance on accomplishing these goals:...
1
vote
0answers
75 views

Capturing keyboard events for a limited time

I'm trying to code a kind of simple video game where there are two kind of players: Human Players: They enter an keyboard input CPU Players: A random input is calculated For Human Players there is a ...
1
vote
0answers
33 views

DNN9 platform display issue

I just install DNN9 and try write module on it. I found a display issue. RESX:NVA_CONTENT.TEXT should be an icon. I also write a simple code on edit.ascx and when click edit module page will ...
1
vote
0answers
189 views

Emberjs acceptance testing - should I mock services?

For ember acceptance tests is it best practice to mock services? This seems strange to me as I would expect an acceptance test not to have to mock anything as it's testing an entire system. Also, some ...
1
vote
0answers
477 views

Best way to handle large amount of objects

I'm building an javascript application where I need to register devices to an specific room. So I thought, I'm making my room_name as main key (room name is unique). And I'm going to add the devices ...
1
vote
0answers
692 views

Should I use a closure instead of a class when I only have one method?

Lets say I have a JavaScript class that takes a whole lot of settings in the constructor, and then only have one method that the user of the class might want to call multiple times. Here's an example: ...
1
vote
0answers
642 views

How do you handle time unit constants (second, minute, etc)?

I've been writing a lot of time related code recently, and in various files, I always end up re-defining things like var SECOND = 1000; var MINUTE = 60 * SECOND; This gets frustrating quickly. So I'...
1
vote
0answers
310 views

Versioning Practices for Javascript SPA Application

I've developed an SPA using AureliaJS. We use team Foundation server to service our source control, but that doesn't really help with good versioning practices. For instance, with our WPF applications,...
1
vote
0answers
68 views

designing better and crisp server.js (the file which is called to start node application 'e.g. node server.js')

While creating server.js file we need to provide routes information as var Login = require('./routes/login.js'); app.use('/login', Login); Now, suppose the node project is a REST services project. ...
1
vote
0answers
266 views

SystemJS Transpiler - where would it be used

I'm creating a project which uses SystemJS/JSPM. I'm also using TypeScript. Now TypeScript has the option of compiling JS using SystemJS Modules - which I'm doing and all is good. I've created TS ...
1
vote
0answers
153 views

Putting NoSQL DB schemas on front-end, safely

We are using Firebase which is probably similar to MongoDB in that it stores arbitrary JSON structures. We are also using Node.js and so the library in question could in theory be used both backend ...
1
vote
0answers
41 views

Best method to allow user to choose multiple things from my DB?

So I have a "Bars" table in my database and a "Add a Bar" form which allows a bar owner or manager to add his/her business listing to my website database. I also have a "Beers" table in my database ...
1
vote
0answers
372 views

Conceptual similarity between Ruby's and JavaScript's inheritance models

To clear some potential confusion, let me start with the following statements As far as I understand, inheritance is mostly about dynamic dispatch. I understand how virtual pointer table based ...
1
vote
0answers
190 views

Find longest match from a set of possibles, given a string

I’m implementing glossary/dictionary in Javascript. It is populated with a set of terms and their definitions internally, then gets handed jQuery elements and searches the HTML, replacing any of the ...
1
vote
0answers
75 views

Pointers on porting a c++ workflow domain specific language to javascript

I am writing a game in c++ with the v8 javascript engine embedded in it. I have a c++ workflow system I use to tell things how to do specific things. It's nice and I like it, but I need it to work ...