Stack Exchange Network

Stack Exchange network consists of 174 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [es6]

ECMAScript 2015, standardized as ECMA-262 6th Edition

0
votes
1answer
161 views

What is it that is so hard about ES6 modules for Node? [closed]

It seems like ES6 imports for Node have been a bugbear for a while. There is the --experimental-modules flag, or options like using Babel - but AFAIK ES6 modules still aren't supported in vanilla Node....
1
vote
3answers
222 views

How does JS Promises works being single threaded

Javascript is single threaded. What I understand from this is if JS i executing on line of code lets say a function. It cannot go to the next line unless that function has been removed from the stack. ...
1
vote
2answers
95 views

How to declare the need of polyfills publishing jquery plugin (and specially for webpack users)?

I've created jquery plugin that is using modern browser's (Node/Element) features. I'm going to publish plugin as npm package. My wish is not to include polyfills code into jquery plugin, bud declare ...
1
vote
0answers
102 views

ES6(babel): Best practice for create class

I have a Product class. When I attempt to reference this from within a method on the class, I get an error saying this is undefined. To solve this, I have to bind this to all methods. And this, for ...
0
votes
0answers
41 views

Patterns for pre-emptive background work scheduling

Here is problem I hope the community can help me analyze: I want to execute a set of jobs with one background worker (or several). Whenever a job is done, a message is fired, and a listener on the ...
0
votes
0answers
61 views

What is an “artifact”? [duplicate]

In the context of Software Engineering, can someone explain to me in simple terms what an "artifact" is? E.g. "ES6 Artifact", "Spring Framework Artifact". I know what ES6 and the Spring Framework are,...
0
votes
1answer
501 views

Is it okay to use var on purpose in ES6, as opposed to let?

I was really glad that ES6 introduced the let keyword for defining variables. var scoping rules can lead to all kinds of issues, especially when working with loops and event handlers. Even when ...
6
votes
1answer
1k views

Why use `const foo = () => {}` instead of `function foo() {}`

For example, in this Redux video, the instructor always uses syntax like const counter = (state=0, action) => { ... function body here } where I would just use the "traditional" function ...
2
votes
0answers
120 views

Is there an accepted Coding Style for multiple ES6 Arrow Functions?

I'm starting to use ES6 arrow functions more, but haven't found a coding style that I like, especially when chaining them together. e.g., Eric Elliott gives this code: mix = (...fns) => x => ...
1
vote
1answer
1k views

Why tabs are evil in ES6? [closed]

As I have recently started using ES6 in production, I was going through an ES6 style guide (having more than 350 stars on GitHub). This guide mentions at least three times that "Tabs are evil. Don't ...
0
votes
1answer
49 views

Simple algorithm for computing an orderable value from a string

I would like to compute a numeric value for strings containing only /[a-z0-9]/i (ignore case). Later, I want to use this value for sorting rows. For this post, I am ignoring number also. My thinking ...
5
votes
1answer
397 views

Why would I use es6 Set prototype -> 'entries'

According to mdn's "Set" documentation, entries is provided as a convenience method ...to keep the API similar to the Map object, each entry has the same value for its key and value here, so that ...
2
votes
1answer
71 views

Convention where to place unexportable functions

For the example's sake let's say there is a given file math.js. Think of it as a module containing many reusable functions. The content of file is: export function area(shape) { normalize(shape) ...
-1
votes
1answer
255 views

Javascript: Invest in ES6 or learn prototype fundementals [closed]

As a budding software engineer, what is worth time-investment in terms of Javascript? I'm interested in long term payoffs in terms of a deeper understanding of languages, tech, software engineering, ...
1
vote
0answers
231 views

SystemJS Transpiler - where would it be used

I'm creating a project which uses SystemJS/JSPM. I'm also using TypeScript. Now TypeScript has the option of compiling JS using SystemJS Modules - which I'm doing and all is good. I've created TS ...
3
votes
1answer
881 views

Do we need redux here?

In an ongoing project my team is building a new web application that relies heavily on a rest api. As we decided to try react we naturally came to implement redux and a middleware, as we've read this ...
0
votes
2answers
1k views

How to 'read' arrow functions in ES6?

I've been trying to learn some of the new features of ES6, and while most of it makes sense, I'm having trouble grasping the arrow function. I'm not asking so much why it exists as I am how to read it....
2
votes
1answer
759 views

Why can't an ES2015 WeakMap have primitive keys?

There are six primitive data types in JavaScript: Boolean, Number, String, Symbol, undefined, null A WeakMap can't have primitive data types as keys. And a WeakSet can't have primitive values. Why ...
2
votes
1answer
91 views

How do I achieve non-linear non-dependent control flow using Promises (in server-side ES6)

Coming over from the Java world, I am having trouble translating a multi-threaded approach to IO to the ES6 Promises concept of aysnc IO. Many of the examples I have seen on promises show a linear ...
3
votes
1answer
518 views

Any reason to continue using plain strings in ES2015?

My current coding style is to use single-quoted strings as a default, and use backticked template literals whenever I need to concatenate a value into a string. But I'm now wondering what's the point ...
1
vote
3answers
403 views

Is synchronously inspecting a promise an anti-pattern?

ES6 native promises do not allow you to synchronously check if they're resolved/pending/failed or to extract their value. I sometimes need this functionality and thus I have to code it manually. Is ...
6
votes
2answers
253 views

Idiomatic way to write JavaScript class that maintains state and tells you when that state has changed

I am an experienced C++ developer but new to JavaScript. I want to write an ES6 JavaScript class that maintains state. How do I tell when state has changed? I can think of two ways to do this. One ...
17
votes
1answer
25k views

different between ES6 and Javascript [closed]

What is ES6? Is it JavaScript? Or multiple language supporter? I searched for it but can't understand it, especially the page on Wikipedia. Is it better than Javascript? And what can I do in my web ...
13
votes
1answer
4k views

Why doesn't ES6 have thin-arrow functions?

ES6 added fat-arrow functions (=>), which have two major differences from normal functions: shorter syntax (including implicit return if you use a single-expression body) inherit this from ...
0
votes
1answer
306 views

Switching over to the real ES6 / ES2015 [closed]

It is exciting time of having Babel and being able to use all nice nice features. It got me thinking, what happens in the future? Nobody really talks about it. I mean some browsers would eventually ...
31
votes
2answers
17k views

Any point in using ES6 Map when keys are all strings?

Plain object keys must be strings, whereas a Map can have keys of any type. But I have little use for this in practice. In nearly all cases, I find myself using strings as keys anyway. And presumably ...
0
votes
1answer
1k views

Javascript Constants in ES6

What would be the preferred way to create constants in javascript, specifically with ES6? Currently I have a constants class which has methods that return the string I'm looking for. class ...
5
votes
1answer
2k views

Nested classes via a getter (to emulate namespacing)

So, we all know that ES6's introduced syntax is definitely sugar over what we've been doing, previously. That being said, we still don't have namespaces (which would be nice...) The problem that I'm ...
0
votes
2answers
972 views

Is it OK to use Promises for Caching

Is it an acceptable (not surprising) to use promises to cache results? The idea is to generate a promise once, and just return that same promise again on subsequent calls. For example, a getAll() ...
208
votes
6answers
55k views

How much should I be using 'let' vs 'const' in ES6?

I've been writing a lot of ES6 code for io.js recently. There isn't much code in the wild to learn from, so I feel like I'm defining my own conventions as I go. My question is about when to use const ...
4
votes
1answer
871 views

How can 'yield' be added as a keyword in ES6 if it wasn't a reserved word?

yield is not a reserved word in JavaScript, yet ES6 makes it a keyword. I thought the point of reserved words was for backwards compatibility. For example, let and const were reserved, so you couldn'...
244
votes
5answers
73k views

Is there any reason to use the “var” keyword in ES6?

Babel's guide to ES6 says: let is the new var. Apparently the only difference is that var gets scoped to the current function, while let gets scoped to the current block. There are some good ...
1
vote
1answer
394 views

Does ES6 help grow the Ecmascript standard library?

With all the noise about EC6, one thing that I realized I haven't heard about is expanding Javascript's standard library. Javascript has a fairly sparse standard library. You need a 3rd party library ...