Questions tagged [ecmascript-6]

ECMAScript 6 reached feature complete status in 2014. The features vary widely from completely new objects and patterns to syntax changes to new methods on existing objects.

Filter by
Sorted by
Tagged with
1
vote
2answers
66 views

Manipulating an ES6 static class property that is an array

I've been trying to find a way to create static properties in ES6 classes and have found a solution with the help of various Stack Overflow answers (namely this one and this one). However, I also ...
2
votes
1answer
72 views

Simplify SVG creation and manipulation using Proxy

A need I have always found dynamically creating SVG content and filters a painful and messy process. The constant need for conversion from JavaScript values to SVG and back, Access to the SVG ...
1
vote
0answers
43 views

Check an ES6 API implementation: can you see anything terrible?

I have just finished writing an API that implements the FULL w3c protocol for webdrivers. This is my first attempt to write fully ES6 code, along with async/await....
3
votes
3answers
234 views

Lookup country codes with a JavaScript ES6 Map Object

In my application, a country code may be passed from the client as a URL query string or in a header. If there is no country in the URL or headers, then it will default to the United States. The ...
1
vote
0answers
35 views

Handling an array of Promises where we care about the outcome of each

Given some data (a job) like, which is from listening in on a RabbitMQ queue: ...
2
votes
0answers
131 views

Advent of Code 2017 Day 6 (part 2) in Functional Programming (FP)

I wanted to practice functional programming (FP) without using any library but using vanilla JS only. So I took a problem from Advent of Code (the 2nd part of Day 6). You can only access the 2nd part ...
0
votes
1answer
1k views

Generate a set of combinations

For one of my personal projects, I needed an algorithm to generate a set of combinations. I've finally successfully written one. The problem is that this algorithm uses two recursive calls to ...
2
votes
1answer
142 views

Advent of Code 2017 Day 6 (part 1) in Functional Programming (FP)

I wanted to practice functional programming (FP) without using any library but using vanilla JS only. So I took a problem from Advent of Code (the 1st part of Day 6): http://adventofcode.com/2017/day/...
0
votes
0answers
53 views

Advent of Code 2017 Day 5 (part 2) in Functional Programming (FP)

I wanted to practice functional programming (fp) without using any library but using vanilla JS only. So I took a problem from Advent of Code (the 2nd part of Day 5): https://adventofcode.com/2017/...
1
vote
1answer
41 views

Initialize an object with a key at runtime

Often I want to construct an object with a runtime-generated key. Here's how I have been doing it: ...
2
votes
1answer
87 views

Advent of Code 2017 Day 5 (part 1) in Functional Programming (FP)

I wanted to practice functional programming (FP) without using any library but using vanilla JS only. So I took a problem from Advent of Code (the 1st part of Day 5): An urgent interrupt arrives ...
5
votes
1answer
81 views

Advent Of Code 2017 Day 4 (part 2) in Functional Programming (FP)

I wanted to practice functional programming (FP) without using any library but using vanilla JavaScript only. So I took a problem from Advent of Code (the 2nd part of Day 4) You can only access the ...
4
votes
1answer
73 views

Advent Of Code 2017 Day 4 (part 1) in Functional Programming (FP)

I wanted to practice functional programming (fp) without using any library but using vanilla JS only. So I took a problem from Advent of Code (the 1st part of Day 4): A new system policy has been ...
2
votes
2answers
84 views

Invalidate a JS Object when any of its values is null or empty

I created a simple Javascript method to recursively parse a JS Object and find out if any of its values or sub values is set to null or is empty string. I could't ...
3
votes
0answers
94 views

Advent of Code 2017 Day 3 (part 1) in Functional Programming (FP)

I wanted to practice functional programming (FP) without using any library but using vanilla JS only. So I took a problem from Advent of Code. https://adventofcode.com/2017/day/3 You come across ...
1
vote
1answer
87 views

Advent of Code 2017 Day 2 (1) in Functional programming (FP)

I wanted to practice functional programming (FP) without using any library but using vanilla JS only. So I took a problem from Advent of Code - i.e. Day 2: Corruption Checksum (below is the 1st part ...
3
votes
1answer
171 views

Formatting mm:ss to string with Javascript

I have a function that takes a time of minutes and seconds, and converts it to a string in the following way: '0:30' would become '30 Seconds', '1:30' would become '1 minute 30 seconds', '2:01' would ...
1
vote
1answer
192 views

Project Euler 8: Largest product in a series in Functional Programming (FP)

I wanted to practice functional programming (fp) without using any library but using vanilla JS only. So I took a problem from Project Euler: The four adjacent digits in the 1000-digit number that ...
2
votes
3answers
341 views

Project Euler 6: Sum square difference in Functional Programming (FP)

I wanted to practice functional programming (fp) without using any library but using vanilla JS only. So I took a problem from Project Euler: The sum of the squares of the first ten natural numbers ...
1
vote
1answer
69 views

Single Page App - Browser Storage API Design

I'm working on building a Browser storage handler for my single page application. The idea is that you make an API call and the API calls the storage handler which either returns the local/session ...
3
votes
1answer
66 views

Multi-field sorting

A function to sort data on multiple fields. I welcome feedback. ...
3
votes
2answers
2k views

Given a number: find the closest value in a list of unique and sorted numbers with some twists

I have a method getClosest() in an object, that does the following: Given a number: Find the closest number in a list of unique and sorted numeric values. On ...
3
votes
2answers
2k views

Tic Tac Toe - Object Oriented JS Implementation

I have programmed a Tic Tac Toe game using Object Oriented JavaScript and ES6 Classes. The program works as planned, but I wonder if some parts of the code can be made cleaner or more efficient. I'...
7
votes
6answers
2k views

Setting flags to show three buttons

I have this loop that iterates and assigns a variable to true depending on the different conditions ...
1
vote
1answer
47 views

Checking for files that are mentioned as children of other files

I am working in JavaScript on a GruntFile script, and I am creating an object that holds a file class for each one of the following class structure: ...
0
votes
2answers
94 views

Function that returns value based on specific category

This is a pretty simple function that returns a value based on the variable category. I tried to use switch instead of define ...
0
votes
1answer
30 views

Merging array entries referenced by indexes in another array

I have one question list (q_arr) and the user can either skip or attempt that question. In the end of last question, I display all question with their selected ...
6
votes
2answers
176 views

Soccer field map creator

I am fairly new to OOP and am working on a little website project to practice. I wanted to post after getting the initial setup done in case I am making any major errors or not following best ...
-3
votes
2answers
103 views

Check if a variable is one of a set of valid strings [closed]

We need to check if a given variable is either "get" or "post". If it's neither then I should throw an error. My teammate and I ...
6
votes
2answers
116 views

Starship Comparison App with ES6 Generators and the Star Wars API

Assignment Description: Make a web application that compares starships based upon the Star Wars API. There shall be: A label "Select two Starships from the dropdown lists to compare". Two dropdown-...
1
vote
2answers
59 views

Function that shows markers all at once or with a delay

I have some markers on an image. At some point all these markers are inactive (i.e. a class name is added to the element, which hides them) and need to be shown ...
4
votes
1answer
382 views

Analog Clock in JavaScript

I have been reading Clean Code and yesterday I completed day 2 of JavaScript 30. I tried to make the JavaScript I wrote for this as clean as possible. This is probably some of the cleanest code I've ...
2
votes
1answer
96 views

Slider on JavaScript

I created slider on JavaScript(ES2015). And I just want to be sure that I did my slider good. With all best practise and rules nowadays! thank you for help Here is my html: ...
8
votes
1answer
4k views

My own “Cookie Clicker” Game

I tried to make my own Cookie Clicker Game. It's inspired from this game. Here I just wanted to practice object-oriented programming in JavaScript (and in general) and get experience in game design. ...
1
vote
0answers
530 views

React, Redux and SignalR connection dependent on global jQuery

I'm writing a react/redux application and I'm on a stage when I need to connect it with backend made with .net using a signalR socket connection. At the moment I've established interconnection ...
3
votes
1answer
695 views

Mapping key value pairs between two JavaScript objects

I have two JavaScript objects: ...
-3
votes
1answer
65 views

Removing Redundancy

I was told I should post this code here because I have a good amount of redundancy in the code. I am new to JS and would appreciate any help in condensing this code and having it still function the ...
2
votes
0answers
94 views

Truly private JavaScript class members (ES6)

I've found pretty simple and clear pattern which can be used to make any data members truly private (invisible, inaccessible) without affecting class behavior (no prototypes and ...
4
votes
1answer
170 views

Simple form validation module

Thinking about form validation, I just wanted something simple that works and is extensible. I came up with the following code, which expects a list of selectors that maps to one or more functions ...
5
votes
3answers
525 views

Secret Santa pair allocator in JavaScript

I have a Secret-Santa gift swap with my family and we always forget who we had last year and never find time to do it so I wanted to create a simple web app to manage the whole thing. What I'm looking ...
3
votes
1answer
59 views

Function that returns words in string not exceeding max number of characters

I'm trying to create a robust function that receives a string -- typically a paragraph or two -- and the max number of characters in the output. One condition is to make sure that we return full words ...
1
vote
0answers
143 views

React Bitcoin Exchange Single Page App

I've got a simple single page web app that's build with React. It fetches data from two different APIs, when they have been successfully retrieved, and the promise ...
4
votes
2answers
1k views

If non-array property exists convert it to one and push new value

Is there a simpler/shorter/better way to do this? ...
1
vote
1answer
38 views

Forcing array of promises to complete before returning

I'm making one call to a mongoDB database to fetch a list of existing collections and then looping through the collection list and fetching their document count. All db methods are promises and i'm ...
5
votes
3answers
890 views

Sorting an array of objects by a property which may be missing

Problem I am sorting an array of objects. Each element may have a property called reference or it may be undefined. When ...
0
votes
1answer
531 views

Creating a ES6 class for every API endpoint's response

Background I am writing a Node app that queries a third-party Web API. The API returns JSON data in various formats, each endpoint in a different format. My app later processes this data. I have ...
2
votes
2answers
410 views

Web-App for to determine gender, age, emotions of a person (shown on an image)

I have made an app using Microsoft's Face API: Face API JavaScript Quick Start It shall analyze an image, showing a person's portrait, concerning the gender of the person, her/his age and emotions. ...
4
votes
1answer
1k views

My first animated data grid with Vue.js

Because this is my very first attempt to create a data grid with Vue, I would like to know about all misconceptions used in my approach. Whomever points to the most important shortcoming / weakness in ...
5
votes
2answers
171 views

Asynchronous JavaScript to fetch remote JSON data with promises and generators

I am trying to figure out how to do async calls using promises and generators (without 3rd party libraries). Most of the examples I found on the Internet are either incomplete or confusing (at least ...
1
vote
2answers
75 views

SQL-style join on arrays using ECMA6

I have a code snippet which performs an SQL-style join on objects in two arrays based on a specific field (in the code below, .id). ...