Questions tagged [ecmascript-6]

The 2015 version of the ECMAScript specification, now a standard (ECMAScript 2015). Only use this tag where the question specifically relates to new features or technical changes provided in ECMAScript 2015.

ECMAScript 2015 (also known as ECMAScript 6) is the 2015 specification for the language (now superseded by the yearly released versions, managed by TC39). ES2015 adds significant updates to the language and its implementation in major JavaScript engines is almost complete (except legacy browsers, like Internet Explorer).

The tag or its alias should be used when your question covers one of the ES2015/ES6 features.

Related, transpiler specific tags are: ,


Features

  • Arrow functions
  • Classes
  • Enhanced Object Literals
  • Template Strings
  • Destructuring
  • Default + Rest + Spread
  • let + const
  • Iterators + for..of
  • Generators
  • Unicode
  • Modules
  • Module Loaders
  • Map + Set + Weakmap + Weakset
  • Proxies
  • Symbols
  • Subclassable Built-ins
  • Promises
  • Math + Number + String + Array + Object APIs
  • Binary and Octal Literals
  • Reflect API
  • Tail Calls
  • Typed arrays and DataViews

Useful Links

29895 questions
13
votes
1 answer

for loop in react

I got this function working to get some gym classes from a .json file. filtrarClase(dia, hora) { let data = this.state.data return data.filter(clase => { if ((clase.dia === dia) && (clase.horaclase === hora)) { return…
Adolfo Onrubia
  • 1,781
  • 13
  • 22
13
votes
3 answers

How to handle nested default parameters with object destructuring?

I am trying to figure out if it is possible to handle multiple levels of default parameters with destructuring. Since it is not easy to explain with words, here is a step-by-step example... 1 - Flat object destructuring with default…
13
votes
2 answers

javascript 'let' and 'var' in for-loops

On my search for concrete numbers to back usage of the const keyword in Javascript, I stumbled upon a performance comparision between all three variable declaration types var, let and const. I didn't like the test setup, so I created a simplified…
koehr
  • 769
  • 1
  • 8
  • 20
13
votes
3 answers

VueJS Use prop as data-attribute value

I am really struggling with the following scenario: Some index page:
13
votes
1 answer

Object.assign and proxies

Having the following object: let obj = { id: 0 }; and the following Proxy: let objProxy = new Proxy(obj, { get: (target, name) => { if (name == "id") return "id from proxy"; }}); Is it possible to "retain" the Proxy after an…
Philip Kamenarsky
  • 2,757
  • 2
  • 24
  • 30
13
votes
3 answers

How to create a Deep Proxy (aka Proxy Membrane)?

How can I create a deep/recursive Proxy? Specifically, I want to know whenever a property is set or modified anywhere in the object tree. Here's what I've got so far: function deepProxy(obj) { return new Proxy(obj, { set(target,…
mpen
  • 272,448
  • 266
  • 850
  • 1,236
13
votes
2 answers

What does three dots do in ReactJS

const peopleList = this.state.people.map( x => { return }) What does "{...x} " this code mean?
Michael Tsai
  • 751
  • 2
  • 11
  • 21
13
votes
1 answer

Functional programming and DOM manipulation

How is most "pure" way to manipulate DOM in script written in "functional" way. For example if I simply need to change element width should I use typical syntax like: document.querySelector(".class").style.width = ... or write dedicated function,…
przemekk
  • 351
  • 3
  • 10
13
votes
2 answers

When should I use brackets with imports

I have two file, the first one is todoHelper.js it has export const addTodo = (list, item) => [...list, item] later on I want to use addTodo in another file, I simply do import {addTodo} from './todoHelpers' But I'm also seeing people doing export…
Zea Lith
  • 421
  • 1
  • 7
  • 15
13
votes
3 answers

How to abort a fetch request?

I've been using the new fetch API instead of the old XMLHttpRequest It is great but I am missing one crucial function, xhr.abort(). I can't find any information about that functionality for fetch. Thanks. UPDATE: hacky workaround for aborting…
Royi Mindel
  • 1,258
  • 12
  • 35
13
votes
2 answers

Can someone explain the 'super()' keyword in ES6 Javascript (especially related to React)?

I'm learning React.js, and I see the super keyword used a lot in constructor functions. I understand that super allows a subclass to have access to the this keyword. However, I can't find much more explanation. Why does calling super(), magically…
thatDubstepSound
  • 337
  • 5
  • 18
13
votes
6 answers

Passing additional parameters in higher-order functions

Consider this example: const samples = ["foo", "bar"]; const excludeFoos = function(item) { return item !== "foo"; } const foos = samples.filter(excludeFoos); How can I pass an additional parameter in excludeFoos? For example: const…
nicholaswmin
  • 21,686
  • 15
  • 91
  • 167
13
votes
1 answer

Capturing all chained methods and getters using a proxy (for lazy execution)

Context: Say I've got an object, obj, with some methods and some getters: var obj = { method1: function(a) { /*...*/ }, method2: function(a, b) { /*...*/ }, } Object.defineProperty(obj, "getter1", {get:function() { /*...*/…
user993683
13
votes
2 answers

Illegal constructor with EcmaScript 6

First of all I would like that say that I don't really know how I can explain what I did on order to get the error mentioned in the title (uncaught TypeError: Illegal constructor). I am using gulpfile in order to compile my Ecmascript 6 to plain…
Eran Machiels
  • 729
  • 2
  • 8
  • 17
13
votes
1 answer

What is the default value of React.PropTypes.func

What's the correct value to replace the question marks with and why? RecentProjectsSection.propTypes = { onClose: React.PropTypes.func.isRequired, projects: React.PropTypes.array.isRequired, }; RecentProjectsSection.defaultProps = { onClose:…
U r s u s
  • 6,680
  • 12
  • 50
  • 88
1 2 3
99
100