ECMAScript (commonly referred to as JavaScript) is primarily used for scripting web-pages but also has several embedded forms and stand-alone interpreters / JIT engines. Use this tag for questions regarding ECMAScript 5 or 6 and its dialects / implementations: JavaScript, JScript, etc., excluding ...

learn more… | top users | synonyms

0
votes
1answer
15 views

JavaScript function for to find a defined element within a nested array

Following task: You've got an array which contains parts. Parts can contain subparts. Subparts can contain further subparts and so on. For example: ...
0
votes
0answers
9 views

Collect several API call results

Want to brush up my rusty web dev skills. I want to call the twitch API for several channels and eventually call a callback function when all results are in without using a sync call. I didn't work ...
0
votes
0answers
13 views

Javascript pager logic

I implemented a function for pager link creation, it looks like this: ...
2
votes
0answers
13 views

Restructure of Node 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 ...
0
votes
0answers
8 views

Simple channel broadcaster via NodeJS websockets

I have a system in PHP and I was asked to add some real time features. I was wanting to learn NodeJS so I considered a opportunity to kill two birds with one stone. But after some search I was unable ...
0
votes
0answers
21 views

Binary search tree and breadth first search

I have written code to implement Binary Search and Breadth First Search in JS. Please review my code. I want to ensure Im following the best practices. Node.js ...
3
votes
1answer
48 views

Event delegation without jQuery

I created event delegation like concept which is present in jQuery. AFAIK, event delegation is used to register an event for an element which is supposed to be added dynamically. So, in jQuery we do ...
3
votes
2answers
42 views

Count calls and update table accordingly

This is literally the first time I've ever used JavaScript so I know it's really bad and how to improve it just not how to implement it. Basically, I need to loop through all the elements instead of ...
3
votes
0answers
21 views

Count groups of open cells around a cell on a grid

Consider a 3x3 square surrounding a cell (marked @) on a grid: 0 1 1 1 @ 0 1 1 1 I need to find the number of groups of open cells (ones) surrounding the center ...
0
votes
2answers
47 views

Minimum element in a sorted rotated array

A sorted array [0,1,2,3,4,5] when rotated n times (3 times in this case) becomes [3,4,5,0,1,2], meaning elements in the front move to the end. The code below finds the minimum element in this array, ...
1
vote
2answers
83 views

Show/hide text field depending on select option

I'm new with JavaScript and need your advice. The idea is to show/hide text field depending on select option. I have a working code, but I believe it could be more readable and better. What have I ...
0
votes
0answers
23 views

PageVisibility API, to handle page/tab visibility changes

Currently, I'm working on a project where I needed to run some code everytime the page is hidden. I searched high and low and found this question: Is there a way to detect if a browser window is not ...
-1
votes
1answer
38 views

Changing sales stage

I think this code is not optimized: ...
0
votes
1answer
41 views

Calculating an object's stopping distance

I'm trying to smooth the movement of a cursor which has a set acceleration and max speed. I wrote this function to calculate the stopping distance of an object given its speed and acceleration, and it ...
2
votes
0answers
26 views

Weather Application - Reavling Module Pattern

I'm trying to practice and learn design patterns, and I decided to create a weather app using the revealing module pattern. How can I improve on this, and what mistakes did I make? Main.js ...
1
vote
0answers
13 views

jQuery templating with ES6/ES2015 template strings

I have been using a particular pattern over and over again when I want to keep my jQuery apps more safe from XSS. I do something like this. (It uses ES6 template strings) ...
2
votes
1answer
28 views

Using fetch() and a new Promise object to get API results

I've written an ES6 function using the new fetch() API and returning a new resolved promise with a data object or a rejected promise with an error subclass. I'm pretty new to both ES6 and Promises, ...
1
vote
1answer
11 views

Promise.spread “Polyfill”

I have written this "Polyfill" for Chrome's Promise object and I have some concerns about the implementation; Does it actually work as designed? It seems to work ...
0
votes
0answers
7 views

Using an object to keep track of rooms and the users within them, for socket io

I'm using socket io. I need to keep track of rooms and the users within them as users leave and join. I've come up with this, is there a better more efficient way performance wise? Many thanks! :-) ...
2
votes
3answers
79 views

Javascript Ownership Cost Calculator

Javascript newbie here. I built a total cost of ownership calculator to calculate the cost of a business over 5 years. It has a lot of repeating script and prob way more congested than it needs to be ...
6
votes
2answers
81 views

Beginner's Calculator code

I am trying to learn AngularJS as a start to my revival of learning, I think that I am getting the hang of it so far, but would like to see what I can do differently with some super simple ...
0
votes
0answers
17 views

Event Delegates using IIFE or Module

I am learning jQuery/JavaScript best practices and am attempting to put them into practice. My overall goal is to have lots of small, independent .js files which contain specific functionality and ...
0
votes
0answers
14 views

Light-weight JavaScript VC Framework

I've always been frustrated with js frameworks in that they require you to learn a lot of custom syntax (ie angular). Typically also they tend to include a lot of extra baggage that takes away from ...
2
votes
1answer
42 views

Simple console directive, revised using provider

I recently created my first directive based on jQuery plugin and I asked for review here: Angular console like window - first directive I've edited my directive so now instead of ...
1
vote
1answer
46 views

Converting an SVG polygon path from relative to absolute coordinates

This question was moved from StackOverflow as suggested by some users. I developed a function that aims to (should) provide a simple and effective method to transform a polygon ...
2
votes
0answers
29 views

Node my Chatter

In an effort to teach myself Node.JS and truly delve into its communication capabilities, I elected to recreate a previous chatting project. It took a bit of forethought to acclimate code to the ...
3
votes
0answers
43 views

Slow multiplication in a modulo

I am willing to get a linear output of a product in a ring Z/nZ For that I have successfully implemented a code that does a Product in a modulo However, it is not optimized to output the steps ...
3
votes
1answer
52 views

Explosion animation plugin for a game

I have been writing a small particle plugin since I want to learn how physics works for games. Now I have tried to get this as clean as I possible could but It feels something is missing. Am I ...
1
vote
1answer
34 views

Angular console like window - first directive

I've asked question on SO how to rewrite jQuery code to Angular. Because I got no answers I've tried to create something by my own. This is my version of code: ...
3
votes
2answers
176 views

Display or hide drawer with onClick

The following is my code for my "drawer" to be display or hidden on the basis whether it has been clicked or not. I want to make this better as personally its messy. Any tips? ...
2
votes
1answer
67 views

Object-to-array flattening function

I have written a function that is designed to convert an object into an array of key/pair values ("flattening it") like so: Input ...
0
votes
1answer
21 views

JavaScript function for logging the members of an object (with horizontal alignment)

When iterating over the members of an object for logging the keys / values one gets a "stair case" effect. Therefore I wrote myself this function which takes care for a left-alignment of the values. ...
7
votes
1answer
60 views

JavaScript canvas sphere

I made a small demo in JavaScript using HTML5 canvas, which renders a rotating sphere. The sphere is generated by first creating a set amount of points (currently 50, represented by vectors) randomly, ...
6
votes
4answers
885 views

Python, JavaScript, PHP, HTML: Unbeatable Tic Tac Toe

At first, I created an unbeatable Tic-Tac-Toe in Python. However, I wanted a better interface, so I used a PHP backend that runs the script and a simple JavaScript that sends user commands to the ...
1
vote
1answer
58 views

Match values inside object and add them

Does the following code is written correct witout redundant code ? or maybe using Jquery it can be written better? I need to find matching between properties insdie oData & oPushObj and fill ...
1
vote
2answers
137 views

Parsing two digits

This parses two digits and returns the rest of the string. Input: "20asg" Output: { number: 20, left: "asg" } Input: ...
4
votes
4answers
145 views

Helper function to format-output any type of variable

This question has already got some reviews, so I could partially improve my code: please look at my "own answer" below, which also contains comments about the review. (I first added all that inside ...
1
vote
1answer
42 views

TicTacToe Win Checking

I decided to finally write up a Tic-Tac-Toe implementation. Since I'm currently learning web development, I decided to write it in JavaScript. My main problem, and what I want reviewed here is my ...
2
votes
2answers
42 views

PE # 34 - “Digit Factorials” with no loops

I posted a similar question “Curious Numbers” (HackerRank PE 34) recently (but in a different language/platform altogether). I'm starting to learn JavaScript and decided to take the challenge again ...
2
votes
2answers
48 views

Using a timeout to simulate a spinner

I am going deep on this array in order to make an id comparison. I want to know if there is a way to use like a kind of flatten function to avoid using ...
0
votes
1answer
18 views

Angularjs alertservice and alertscontroller

I'm a .net programmer with littler experience in AngularJs and Javascript. I have implemented an ...
1
vote
1answer
46 views

AngularJS controller to fetch and display employee data from database

This is the code for an AngularJS controller that I've written: ...
0
votes
3answers
87 views

How could I refactor this if statement?

I have a code which checks if any of the 4 textfields on our server contains text. If even one of the four textboxes is not empty, the generated table won´t skip that row and will draw it, otherwise ...
-3
votes
0answers
22 views

Need someone to help reviewing and improving my JS (javaScript) coding [closed]

I need my JS (javaScript) coding to be improved base on the following requirements: PROPER EVENT BINDING: Consider using the preferred .on() method rather than .click(), .bind(), .hover(), etc. For ...
3
votes
3answers
84 views

Chess board in JS

I've completed the small challenge in the eloquent JS book to create a chess board pattern: Write a program that creates a string that represents an 8×8 grid, using newline characters to ...
1
vote
2answers
54 views

Sum all numbers in text using regexp

I would like to improve everything that can be improved. I don't understand regex a lot and what could be wrong. The main improve that I am looking for is related with errors. I want make the code ...
-1
votes
0answers
16 views

How filter a grid from a tree list

The Tree has a list of car ids, group by how old was the last update. User can select a group or just a few cars to watch on the detail grid. Im using Jquery Ajax to call my WebApi. With ...
0
votes
0answers
19 views

custom login method using JavaScript and Protractor

I have written login method in JavaScript using protractor. When Login method is called, this methods waits for element (txtLogin) to be present in DOM. Once it finds the element, credentials are ...
7
votes
1answer
69 views

Smoke the SmokeDetector

In Tavern on the Meta, our spam detector is a bot named SmokeDetector. While you can ignore the bot, you can't ignore specific replies to Smokey without ignoring users, so I wrote a UserScript to ...
1
vote
1answer
68 views

Is Nesting Events a Good Practice in Javascript/JQuery?

I posted this question in stackoverflow and they told me it would be better served here so here it is: Is there a more effecient way of changing the mouseout state ...