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
5
votes
1answer
73 views

Using generators to build up a maze

In prepping to teach a workshop on recursion I wrote this code that uses a maze-building algorithm. In doing so I found it really natural to use generators a lot. I feel pretty happy with how the code ...
1
vote
1answer
282 views

Currying addition function in ECMAScript 6

I wanted to write an add function that implemented currying in JavaScript. I welcome criticism and suggestions for improvement. ...
0
votes
1answer
67 views

ES6 call `this` in Array.filter

Does exist a cleaner way to call a static method inside ES6 Array.filter function ? ...
1
vote
1answer
69 views

Long arithmetic addition implemented in functional style

This implementation uses ECMA6 syntax and babel as transpiler. You can use this code to add integers which are bigger than Number.MAX_SAFE_INTEGER. ...
10
votes
1answer
3k views

HashMap and HashSet classes for ES6

The new EcmaScript standard, ES6, contains specifications for Map and Set built-in classes. Each of these collections treats an ...
2
votes
1answer
1k views

Sum an array of video lengths in JavaScript into HH:MM:SS

I am trying to learn functional programming in JavaScript, and saw a little task on Twitter that I wanted to have a go at: ...
1
vote
1answer
857 views

Knockout computed observables in ES6

I am trying out for the first time knockoutjs and babeljs and have a question on how to do computed observables properly. Both fullName and ...
2
votes
1answer
724 views

Return React child component based on current state

I am trying to build a multi page form widget with React for a website inspired by this. Since quite some time has passed since I last touched JavaScript, I'm directly adapting to ES6/7 and tried to ...
1
vote
1answer
124 views

Node.js drawing game based off of my state diagram

I really want to have a nice design pattern for my Node.js project. This is my state diagram. As I'm coding this, I'm wondering if it's better to separate state logic from the class? So instead I ...
2
votes
0answers
2k views

Flux & async communication with websockets

I want to arrange async server-client communication with websockets and vanilla flux architecture. There is an excellent article about "Async Server-Side Communication with the Flux Architecture". I ...
0
votes
1answer
122 views

Flux: async communication with websockets

I want to arrange async server-client communication with websockets and vanilla flux architecture. There is an excellent article about "Async Server-Side Communication with the Flux Architecture". I ...
3
votes
1answer
52 views

Building a unique array of db fields

This is stripped down from a project I'm working on: ...
10
votes
2answers
157 views

String sequence in ES6

Given an unique string that represents a sequence of characters, the class should implement three methods (getNextChar, getNextString and the genSequence generator). How it works We give a sequence ...
1
vote
2answers
73 views
7
votes
1answer
161 views

Processing files with streams

I'm using io.js. I have to read some files as a stream, process them with the same function, and join them back into a stream. I decided to create my own solution with ...
6
votes
1answer
135 views

Generate probabilities around a numpad

Currently, I'm working on a game with directional movement influenced by the numpad. The player AI should intelligently pick a direction to move (so it's not entirely random, and can be somewhat ...
4
votes
1answer
190 views

Project Euler #55 - Lychrel numbers

If we take 47, reverse and add, 47 + 74 = 121, which is palindromic. Not all numbers produce palindromes so quickly. For example, 349 + 943 = 1292, 1292 + 2921 = 4213 4213 + 3124 = 7337 ...
5
votes
1answer
489 views

Class(es) for animating objects on a canvas

I'm building a simple canvas animation engine as an exercise in learning ES6. Coming from C++ and Java, I miss static properties, but I've read that "Prototypes having data properties is generally ...
11
votes
2answers
912 views

Hello, First Name Last Name

I've been working on learning React, and so like most people do when they get started on something new. I created an arbitrary simple project to get a bit more familiar with the concepts. It's so ...
2
votes
1answer
492 views

Dependency Injection with classes which are created often

I have a question about dependency injection and best practices when using simple classes which are meant to be created often, which have dependencies on external services. Here's a (vastly) ...
10
votes
1answer
192 views

Hunt the wumpus: Functional JavaScript (Node) with Lodash

I'd like a code review of the following simple implementation of the classic game Hunt the Wumpus I'm trying to use JavaScript in the most "functional" way. To help me, I'm using lodash and ES6. <...
4
votes
1answer
274 views

Salsa20 stream cipher

I have been implementing Salsa20 by studying the design and specification. I have made sure to unit test every function along the way and match the outputs against the test vectors in the spec. I am ...
2
votes
1answer
100 views

99 bottles of beer on the wall + EcmaScript 6

Today, a solution written in Python was posted to this challenge, and since I was inspired by it, I made a version in EcmaScript 6. I tried to explore some new language constructs: arrow functions ...
2
votes
1answer
70 views

Get friend lists

I've never written on VKScript (and on Javascript). I need high performance code to get more friend lists faster. ...
1
vote
1answer
2k views

ES6 classes and ReactJS: implementing propTypes

I had a problem to define propTypes for my React class. I ran into solution that doesn't feel right: ...
4
votes
1answer
1k views

Toggling element class according checked radio input V2.0

This question is about an improvement of the code from this previous question (previous changed visibility, new applies a CSS class with a border). It is a constructor function that attaches a click ...
15
votes
2answers
669 views

JavaScript/ECMAscript 6 classes organization

I have been trying to wrap my head around all the new options in ECMAscript 6 and to do this I tried to develop a simple setup which would allow me to place absolutely positioned ...