Questions tagged [javascript]

ECMAScript or ES (commonly referred to as JavaScript) is primarily used for scripting web-pages but also has several embedded forms as stand-alone interpreters or JIT compilers. Use this tag for questions regarding all versions of ES up to the current ES8 and its dialects / implementations: JavaScript, JScript, etc., excluding ActionScript.

1,088 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
7
votes
1answer
717 views

Datepickers for departure and return dates

I have to two datepickers. I want achieve the following functionality: the return date cannot be selected before the selected departure date and the departure date cannot be after the selected return ...
6
votes
0answers
238 views

PEG.js grammar for a simple programming language

I'm trying my hand at developing a compiler and have written a PEG.js grammar for a simple programming language. A sneak peak at the grammar: ...
6
votes
1answer
1k views

Scroll animations - setInterval vs. setInterval & requestAnimationFrame

I've recently made a slightly similar question with respect to the rendering performance, however my question this time is a bit different and with respect to which kind of JavaScript approach is the "...
6
votes
1answer
226 views

Voting app in JavaScript using Ramda

I'm just learning functional programming in JavaScript using Ramda. I took this tutorial and implemented the server core.js component using Ramda. The idea is that we'll have a collection of ...
6
votes
1answer
1k views

Prevent multiple async calls from all attempting to refresh an expired OAuth token

I have some code that needs to access an API that requires OAuth authorization in the form of a token, and every time the token expires, it needs to be refreshed. I made a function called ...
5
votes
0answers
81 views

NodeJs crawler for recipes

Here is my try on a crawler made in nodeJs with cheerio, I made it with the idea in mind to use it in a future project I wanna make. Here is the git link: https://github.com/Just4lol/CookCrawler If ...
5
votes
1answer
66 views

Filter by multiple options - also only if not empty

Here's how my json looks like. I'm trying to write a function which filters based on participantCriteria.criteriaType & participantCriteria._id ...
5
votes
0answers
195 views

Spacial hashing Library

Old code ...
5
votes
0answers
175 views

Object-Oriented Sorting Algorithms

I would like a review of a library I've recently published. I realize this is a rather large request, but having looked on meta, it seems this is perfectly on-topic. I'll include a few choice samples ...
5
votes
0answers
322 views

Object-oriented fractal tree

I made an object oriented fractal tree in javascript using the p5 library, it consists of three files: Fraternal Tree.js branch.js flower.js Here is the github repo with the source code. All the ...
5
votes
0answers
152 views

Assembling and traversing a graph, given a list of items and parent pointers

I've written a function which takes input such as this: ...
5
votes
0answers
75 views

Using components instead controllers in EmberJS v2

I am beginner in EmberJS. I have made todomvc for ember v2 for learning Ember. My implementation works without controller. I use components instead controllers. In the documentation I see: ...
5
votes
0answers
1k views

Mocking the file system within a test

I've been using this method to test file-system functions as an alternative to mock-fs due to its lack of symlink support. I'd love to hear what others think and ...
5
votes
0answers
695 views

Exiting a Promise early

I'm using a Promise chain to write some data to a file, execute a command on it, inspect its results, and send the results, using Express.js. The thing about my function is that I need to be able to ...
4
votes
0answers
35 views

Border Radius Preview Tool

I am running through an app idea to help improve my knowledge of Javascript. The code attached performs the following: Performs a regex on the input field to check it is value 0-9 If not, it clears ...
4
votes
0answers
34 views

Vuejs - input validation

I'm in a project that's currently using vue. I'm at the moment developing validations for the inputs and in a way to make them more flexible, my idea was to create an intermediate component "Group ...
4
votes
0answers
51 views

Chess AI Using Minimax and Alpha-Beta Pruning

I am working on a Chess AI using chess.js, and currently, it can run 3 layers in under 10 seconds, but 4 or more takes minutes. How can I optimize my current code to be able to run 4 or 5 layers, or ...
4
votes
0answers
27 views

Get current user middleware from JWT using express

I'm using Sequelize and Google oAuth for authentication, I want to create a middleware that Verifies the sent token passed in the headers matches the one the user was initially signed to. Finds the ...
4
votes
1answer
231 views

Node.js http retry do while mechanism

I have implemented a simple do/while loop to handle a http request to a third-party. I don’t know when the data I receive will have elements in its array so I retry up to 10 times until the array ...
4
votes
1answer
57 views

Select members based on activity

I was asked by a friend to write a simple page for selecting members to various tasks. The members are listed in a textfile, along with how much they are willing to contribute (Usually a number ...
4
votes
0answers
1k views

Get checkbox value of unchecked checkboxes in a table

I have a table where a user can (un)check checkboxes among other features in each row. I faced the problem that I don't receive unchecked checkboxes to my backend. This led to a bigger issue since ...
4
votes
0answers
144 views

Sierpinski triangle html canvas Implementation

I wrote my Sierpinski Triangle fractal animation using html canvas with js: JsFiddle Code: ...
4
votes
1answer
114 views

Fetching data from API in JavaScript

I'm using Axios to fetch data from an API, and don't know if this is the best way to deal with APIs in ReactJS or not. I want to know if anyone can suggest edits or something to make the code more ...
4
votes
1answer
76 views

Resource closing in a promise chain

This is some code that fetches a result from a database. It connects, makes a query, processes the query, then has to close the DB (under all possible code paths) and return the result. It seems ...
4
votes
0answers
31 views

Parsing root-level elements out of HTML fragment file

I have the following code written in NodeJS, using the parse5 library. It's purpose is to parse out the root-level elements in a file containing HTML fragments (Vue ...
4
votes
0answers
51 views

Node secure randomness implementations

I'm trying to generate secure randomness in Node as a personal challenge. I was wondering if the following implementations are correctly random or they have some flaws. ...
4
votes
0answers
82 views

UI testing for a web application, with variant scenarios

I'm pretty new to software testing and am currently working on a cloud-based web application. Briefly, the application uses: Ext JS as a framework Bryntum's Siesta framework for testing Currently, ...
4
votes
0answers
37 views

Apply arbitrary action during recursive generator function

I've got this recursive generator function. It will traverse an object looking for "leafs", any keys that don't point to sub-objects. Then it applies one of two actions on the leaf and yields it. Any ...
4
votes
0answers
92 views

First Javascript program - Snakes game on HTML canvas

I'm relatively new to programming but my most familiar languages are Java, C# and Haskell and this is my first javascript program. All the concepts used in here were just the first thing that came to ...
4
votes
0answers
160 views

React.js defaultMemoize as container

this is the code I wrote ...
4
votes
0answers
64 views

Controlling Finances with Web Development

Purpose First, let me explain the title: I previously had managed my finances like an old fashioned company might, and it worked wonders for making financial decisions (at least for me). I wanted my ...
4
votes
0answers
541 views

Generating Bitly links in a Google Sheet

I have this set of functions in my Google Sheet to create a Bitly bitlink whenever data in a row is changed. While this does work, it seems really slow to me. Looking at the Execution transcript, it ...
4
votes
0answers
317 views

Dungeon crawler map using JavaScript

I finally made a "full dungeon crawler map" thanks to this. The map looks great to me and I'd like to hear some useful advice from you. What I'm trying to do is to simplify my logic about 'detect ...
4
votes
1answer
1k views

Generic dataloader for redux-thunk using axios

I am developing an application where there are lots of async actions. I wanted to go with redux-saga but most have insisted to continue with redux-thunk. In redux-thunk, inside each action we have to ...
4
votes
1answer
150 views

Hoc462 - A Raycaster

For the past week, I've been making a raycaster in JS and if you want a live demo, you can try it here. It ran smoothly before I added variable height walls but now it is very slow (~15 FPS) so I want ...
4
votes
1answer
518 views

Module with helper functions to initialize or reinitialize a Slick carousel

I been getting into javascript patterns and would love to get some feedback. I notice that I got some general helper functions. Is this a good approach of dealing with it? ...
4
votes
0answers
312 views

JavaScript Recursive Filtering With AND and OR

I am doing the #JavaScript30 challenge and challenge 06 is to write a "type ahead" application for searching for cities/states. The basic challenge of filtering based on a simple string was rather ...
4
votes
0answers
698 views

Vanilla JavaScript ToDo List implementation

Just started learning JavaScript and I have created a basic TODO list following MVC concepts to apply what I have learnt so far. This is probably overkill for a simple todo app, but the objective is ...
4
votes
0answers
61 views

Angular directive to fetch resources to fill a table

I created a directive that solves my immediate problem, but I'm trying to find ways to make it more reusable. My immediate problem was, I have a table and needed to fill in one of the columns with ...
4
votes
0answers
158 views

Parsing BibTeX in JavaScript

I have a project for which I need to parse BibTeX strings. In v0.2.9 and before, I used Regex, and I want to change that. I set up a while loop system that reads ...
4
votes
0answers
146 views

2d game enemy entities factories, probably in need of refactoring

So I'm making a 2d shoot'em up game as a way of learning canvas, and larger-scale programming than what I'm accustomed to. I'm a purely front-end web dev, I can't say I'm very experienced in this. ...
4
votes
0answers
134 views

Extensible factory method for starting D3 charts

I'm working on refactoring some existing code to be a bit more extensible and am wanting to create a generic factory API for starting D3 charts. Currently, my factory looks like this: ...
4
votes
0answers
43 views

Reading and updating an XML address file

I have some code that reads from an XML file and updates if needed. I want to move some of the stuff around. Here is the code overall: ...
4
votes
0answers
364 views

Hunt n' Kill algorithm

Last day I implemented the Hunt and Kill algorithm in JavaScript, using HTML5 without any libraries. I would like my code to be reviewed. How it works I start with a 2D array filled with walls (1-s),...
4
votes
0answers
308 views

Passport user authentication

I'm using Passport in Node.js app to authenticate user by email and password (login) and also by token. Email and password are used only when user is logging in. Passport local strategy generates ...
4
votes
0answers
2k views

Finding all paths between nodes in a graph

I wanted to write a function paths that returns the possible routes between two nodes in a graph. For example: ...
4
votes
0answers
228 views

Restructure of Express CORS middleware for unit test

How should one break this component down to better perform unit test on its behaviors? Issues: Authentication middleware component makes external request. Must recognize preflight and final flight. ...
4
votes
0answers
87 views

Angular controller scope inheritance vs service

On my site I have a navbar component that I want to customize for each and every ng-view I end up loading. Currently I'm doing ...
4
votes
0answers
84 views

Backbone learning piece, Movie Application using Views, Collection, Models, Routes and Localstorage

I have created a Backbone Movie app as part of a learning exercise, the app is hosted on codepen although I actually have it built on my local but thought this approach would be handier for code ...
4
votes
0answers
275 views

Cat Clicker MVC

I'm training my coding and wish you guys to see how my code is. I made a cat clicker based on the MVC pattern. Basically it shows a list of cats and when you click a cat name it shows an image, and ...