Tagged Questions
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 ...
1
vote
0answers
9 views
Mocha + should.js, testing for node
I'm new to the world of BDD, but I'd like to get a grip of it as soon as possible. It's one of my first tests:
Fluent.js
...
3
votes
0answers
18 views
Order a delicious pie here
For a quick summary: I've created this internal web application, and I've hit a point where I can really see the mess I've made. I need some help separating the logic, the view, and the data.
More ...
1
vote
1answer
40 views
How can I reduce this code javascript code so it's not as repetitve?
I have a function which goes through every name in an object. This object has an array parameter materials which holds other objects. Those objects have the same array parameter which hold more ...
1
vote
3answers
51 views
Converting text to colored pixels and back again
Any suggestions for improvement or critiques are welcome!
...
1
vote
1answer
25 views
How should I name a function which show or hide an element?
I have a function to display or hide some elements. What I want to do is to manage the display of those elements regarding a value.
Here is a sample:
...
3
votes
0answers
31 views
UI for adding roles and modules to a user list
I have a small UI that involves adding roles and modules to a user database array. The interface works as is, no problem at all, but it seems to have a bit of 'duplicate' code that I was hoping I ...
0
votes
0answers
23 views
Approach to avoid callback hell without third party modules
I am using the following approach to avoid callback hell. I am curious about what you think since I haven't seen this approach before. What are the pros and cons?
To me the advantages are:
Easy to ...
3
votes
0answers
40 views
Recursive dragon on a canvas
I've been doing some JavaScript for fun again. This time I tried my hand at drawing the Dragon curve - a neat fractal that consists of one line traveling across the plane, never crossing itself, and ...
-2
votes
1answer
50 views
Pass a Boolean to a function or call one of two separate functions [on hold]
Is it better performance or not to call one of two separate functions in response to an if statement over passing an argument to a function? And, what are the ...
3
votes
2answers
78 views
Applying an id attribute based on a variable's value
I have the following code that checks the value of a variable and then applies the correct id attribute accordingly. The value of ...
1
vote
0answers
18 views
Code exercise - Interactive JavaScript Quiz App [on hold]
As an exercise to practice JavaScript, I built a quiz app, for which I would appreciate a short review for improvements. The quiz stores the questions in an array of objects, loads the questions ...
12
votes
1answer
401 views
Capitalize the first character of all words (even when following a '-')
I got it working, all variations are displayed Sint-Anna as should be, but I wonder, is there a simpler way to this, since it looks very cluttered?
...
1
vote
0answers
29 views
Best practice for properties initialization using constructor
I am declaring a "class" using a "constructor method". In both samples, properties uuid and dateCreated are initialized but in ...
0
votes
1answer
26 views
2
votes
0answers
39 views
Implementing Simple and Fast Inheritance in JavaScript
I have been using the John Resig JavaScript class implementation in my web apps, but the tests shows it is really slow. I really find it useful for the way of extending objects, and the benefits got ...
2
votes
0answers
16 views
ThreeJS State Object
state object - a state or scene from the game. When the start function is called, the state starts rendering, shutting down any other state using the renderer, and calling the specified functions ...
1
vote
0answers
24 views
3
votes
1answer
39 views
Check if string can be rearranged into a palindrome
I created a function to test whether a single word string can be a rearranged into a palindrome (doesn't have to be a real word). My logic was if the string has an even number of letters, then each ...
0
votes
0answers
15 views
Node.js log parser for mongoDB
I have developed a log parser, the goal is to take whatever log type I can, and convert them in a mongoDB collection.
I think I've done a pretty good job at reading whatever type of log are trhown at ...
-1
votes
0answers
16 views
Use something other than a modulo for this function [on hold]
I'm wondering if there is another way to write this function without using a modulo to determine how many times a user has clicked and base it off that. It's interfering with another piece of code I ...
0
votes
1answer
93 views
2
votes
0answers
12 views
Assigning JSON object values to objects in a KnockoutJS setup
I am using this for in loop to loop through a JSON object and to assign the JSON object's value to my own object in a KnockoutJS setup.
The JSON object looks like ...
0
votes
0answers
34 views
Super simple jQuery slider
I created the most simple though still quite flexible jQuery slider ever! Or at least, I hope so.
...
4
votes
1answer
45 views
Removing popup notification, the dirty way
I'm new to coding and I am self-taught up to this point, so my scope for creativity is quite limited. As such I'm doing something in particular that I suspect isn't the "best" way of achieving this ...
1
vote
1answer
50 views
Test & remove, or always remove [on hold]
I have a simple function in jQuery I'm using for an event to show a tool tip that may fire a LOT (based on mouse movements):
Code A:
...
4
votes
1answer
33 views
From object to array with revert and regroup
Basically, I need to regroup keys by values from an object to an array
An example worth a thousand words in my case, as I don't know how to clearly explain my problem.
Here is my input object:
...
3
votes
1answer
44 views
Detecting which properties have been changed from two objects
I have the following code. Providing two objects cmd and this.xxx.properties, script detects the only property changed and ...
1
vote
1answer
29 views
Selecting the correct price
What are your opinions on my JavaScript function? Can my code below be refactored?
...
0
votes
0answers
25 views
Handling invalid input and error conditions [closed]
I have this small piece of code which capitalizes first letter of each string in the given array:
...
3
votes
2answers
38 views
Find if an array is arithmetic or geometric
This seems to be working fine. I am pretty sure there is a better way to do it. How can my code be improved performance-wise? The main thing bothering me is the nested ...
0
votes
2answers
45 views
Recurring dates auto selection using jQuery UI multiDatesPicker
I setup my code at jsfiddle. Along the review I want to know the solution of a problem I'm facing in this code.
On click the Edit button I want to enable the calendar which is disabled by default. ...
4
votes
1answer
112 views
Extend jQuery with enable/disable function
I want to create an extended disable/enable function in jQuery. This is working, but is this the best solution? Is each loop necessary?
...
1
vote
1answer
43 views
Removing properties and elements set to null in JavaScript
I'm looking for a review of the following code.
Is there a better way to remove all properties that evaluate to truthy for a given function?
Is there a better way to prevent a stack overflow in the ...
1
vote
0answers
29 views
Hash Table Implemented by Javascript
I recently tried to implement a simple hash table using Javascript. Could anyone help me review my implementation?
...
0
votes
1answer
30 views
Output JavaScript object into HTML table of key-value pairs using jQuery
This function is meant to take an object, loop through the key-values and generate/build a HTML table at a particular ID:
...
3
votes
3answers
74 views
Converting a state from hash into a JavaScript object
This code gets a state from a query string hash part, converts the hash part to a JavaScript object and then tries to get a view, ...
7
votes
1answer
157 views
+50
Multiple inheritance with JavaScript with support of calling of super() methods
I have just finished working on a Node.JS module that provides "multiple inheritance that works". I had some really specific requirements:
Works in safe mode
Auto-calling of parent constructors
...
1
vote
2answers
67 views
jQuery addClass
I am a self confessed jQuery novice but I am conscious of learning the correct techniques. When I can see repetition like this I just know that there must be a better way.
jsFiddle
...
1
vote
1answer
39 views
Repetitive event handler for a toggling UI control
I feel like this bit of code could have been written more elegantly, especially with the huge if/else statements. Can somebody help me break this down? It would really help me out in the future.
...
3
votes
3answers
122 views
Recurring dates within a range
I'm using this code to find out the recurring dates, within a given range. Is this the correct way to find out the recurring dates within a range of dates?
...
1
vote
4answers
102 views
Project Euler #1 - JavaScript
I'm new to JavaScript, and decided to learn the language by running through as many of the Project Euler problems as I have time to do. I just finished the first one, and am looking for some feedback, ...
1
vote
0answers
21 views
Optimizing a ng-repeat tilemap
I am creating an mapeditor web application like tiled
My ng-repeat looks like this:
...
2
votes
1answer
50 views
Optimizing pagination of HTML tables
I'd like to share my implementation to you to confirm if it's a correct way to solve my problem. I have a list of products which have an attributes table and a description table (both in html_encoded ...
3
votes
0answers
35 views
JavaScript/Angular TicTacToe Minimax AI
I am interested in getting some feedback on the code for my TicTacToe game, implemented with Angular, particularly with respect to the AI logic, which is printed below. (The full code base is ...
1
vote
4answers
73 views
2
votes
0answers
32 views
Modelling an automation test controller and test steps
I'm trying to break up some procedural JavaScript code used for running an automation test.
The code is a series of steps that execute selenium webdriver commands within the neustar load testing ...
2
votes
1answer
67 views
Javascript Performance Optimization
I am using the code below that loops around thousands of time, I need this to be as fast as possible, however I am not an expert in Javascript and all I know is that this code is faster than doing it ...
5
votes
1answer
44 views
1
vote
0answers
31 views
AngularJS wrapper for p5.js - p5 directive and service
I wrote an AngularJS wrapper for p5.js called angular-p5:
...
3
votes
2answers
80 views
iPhone notes application replica using HTML/CSS
I've written a web application that is a replica of the iPhone's notes app. It turned out quite well, you can do everything you can on the iPhone's app except for sharing and sending it via texts etc. ...