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.
663 questions
0votes
0answers
30views
Load List of Movies Using useReducer hook
I am learning react.js, and I am on a way learning react hooks. I followed some examples on 'useReducer' where I have a search input for searching movies, and I load the list of movies from API. The ...
2votes
1answer
79views
Axios wrapper used with API requests
I have created Axios wrapper following SOLID principles. Is there any feedback on improving it's structure in a more cleaner and better way? axiosconfig.ts ...
7votes
2answers
235views
Timezone-based VPN-detection
I use the following snippet at my browser homepage to detect whether or not I have VPN turned on. If the IP timezone is different from the browser timezone, then it is most probably VPN is turned on. ...
6votes
1answer
126views
Support Captain Picker in Vanilla JavaScript
I have been tinkering about a program that would pick the support "captain" of the day on workdays with the following rules: Program should only pick a captain on weekdays (Mon. to Fri.). ...
2votes
1answer
38views
Update user name within participants of chats
I have the function which updates user data (currently only name). I would like to optimize its logic and particularly logic of updating participant name in chats. Currently I get entire chats ...
2votes
3answers
198views
Efficiently tagging first and last of each object matching condition
How can I make the code more readable and more efficient? (provided code is O(n²) time, but intuition says it can be pre-processed and done in O(n) time) Description it tags the first and last of ...
5votes
2answers
364views
Full Promise implementation
I have attempted to implement the native Promise object provided by the browser in JavaScript. The code is pretty easy to understand. It supports most of the promise functionalities, such as chaining, ...
2votes
1answer
62views
Combining multiple regexps using the `|` operator and grouping the regexps by their flags
I've implemented a function that creates a multiple regular expressions predicate. The idea behind the predicate is combining regular expressions using the disjunction operator ...
7votes
4answers
881views
ES6 inner join equivalent
Using the sample data from here, I'm attempting to write JS code (to the ES6 standard) that is equivalent to an SQL inner join. The solution below works fine, but it seems rather long. Is there a ...
0votes
1answer
80views
A Chrome extension for analytics debugging: code to render the popup
I made an extension and got it to the point where it does what I want how I want. At this point, I have a little capacity to work on code refactoring, readability and such. And I would love some ...
2votes
2answers
122views
Merge three (or more) arrays based on specific index and create new array
I have three arrays in which first index is same, so I want to merge all three array into one array based on first index element Input: ...
4votes
2answers
452views
Detecting when a user stops typing
I wanted to detect when a user stops typing. I encountered this answer from SO (Not the selected answer, but the second one which seem to be better): https://stackoverflow.com/a/5926782/17746636 But I ...
0votes
1answer
101views
Create and store the level data for a remake of Super Mario Bros game
I am trying to remake Super Mario Bros. in JavaScript and I am trying to figure out if there is a more efficient/shorter way to create and store the level data. I have created 1-1 and here's what the ...
4votes
2answers
192views
Abundant number implementation
I have implementted a simple JavaScript function to find the list of abundant numbers and print them on the screen. an abundant number is a number for which the sum of its proper divisors is greater ...
1vote
1answer
140views
Transform an array into object and set index for an unique key in javascript
I have a method that merges keys and indexes from an array into an object. I'm stuck with ways to compress this method, and I don't know what I can do to make it simpler. Goal get an array of objects ...