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

Why is Babel 7 not compiling node_modules files?

I have error in IE11 SCRIPT1002: Syntax error (problem with class syntax). My simple code with 2 lines: import { struct } from 'superstruct'; console.log('finished'); I wan't that my babel7 compile class into ES5 code I have tried write .babelrc…
zloctb
  • 10,592
  • 8
  • 70
  • 89
13
votes
2 answers

Rendering js from a Rails controller with webpacker

Just replaced the js pipeline in my Rails app with webpacker. Most things work correctly, however controllers that render js no longer work as expected. def action format.js { render "javascript_partial" } end Normally, the above would execute a…
sambecker
  • 1,099
  • 12
  • 28
13
votes
5 answers

How to change swipe direction in swiper.js?

I'm struggling with changing swipe direction when I rotate my swiper on 90deg. So in the beginning by default it has horizontal direction. When clicking on slide I'm rotating "swiper-container" making it full screen . So it still has swiping…
Yerlan Yeszhanov
  • 2,149
  • 12
  • 37
  • 67
13
votes
4 answers

ReactJS multiline textarea with ellipsis

I'm trying to build a component with multiline textfield. If the text entered exceeds 2 lines, then I'd like to add the ellipsis (...) for text-overflow. How can I achieve this by just manipulating the css to show the ellipsis in display only but…
veggirice
  • 246
  • 1
  • 2
  • 15
13
votes
2 answers

What is the difference between loadingIndicatorSource and defaultSource props in react-native?

The defination for loadingIndicatorSource and defaultSource properties are almost same for both. Please, can anyone tell what is the difference between loadingIndicatorSource and defaultSource props in react-native?
user10564429
13
votes
3 answers

What is the correct way to access props in the constructor?

What is the correct way to access props in the constructor ? Yes i know that in the React documentation is said that When implementing the constructor for a React.Component subclass, you should call super(props) before any other statement.…
Norayr Ghukasyan
  • 1,298
  • 1
  • 14
  • 28
13
votes
2 answers

Map over nested array of objects in React

I am trying to map over array of objects which each array contains another nested array of objects. However, the map does not work on the nested array. How do I map over the contents of the nested array while keeping all the content under the same…
alt-rock
  • 347
  • 1
  • 6
  • 18
13
votes
5 answers

ES6 equivalent to lodash _.mapValues

What are the different ways to convert the lodash _.mapValues to ES6. Code: var fruits= { 'apple': { 'name': 'apple', 'number': 5}, 'orange': { 'name': 'orange', 'number': 10 } }; _.mapValues(fruits, 'number'); Output: { 'apple': 5,…
aadhira
  • 321
  • 1
  • 3
  • 16
13
votes
2 answers

Adding proptypes to unnamed anonymous default exported functions - e.i "export default () =>{}"

I know you can do the following: import React from "react"; import PropTypes from "prop-types"; const Header = ({ name }) =>
hi {name}
; Header.propTypes = { name: PropTypes.string }; export default Header However can I assign…
garrettmac
  • 8,417
  • 3
  • 41
  • 60
13
votes
1 answer

Call join() on a generator in JS

In Python, you can call the string.join() method on any iterable, like so: ",".join(some_iterable) The argument may be a list, generator, or any other object as long as it is iterable. Playing around with ES6, I couldn't find a way to do so without…
Nasser Al-Shawwa
  • 3,573
  • 17
  • 27
13
votes
3 answers

Stub an export from a native ES Module without babel

I'm using AVA + sinon to build my unit test. Since I need ES6 modules and I don't like babel, I'm using mjs files all over my project, including the test files. I use "--experimental-modules" argument to start my project and I use "esm" package in…
Jim Jin
  • 1,249
  • 1
  • 15
  • 28
13
votes
3 answers

javascript constructor with optional parameters

I am learning Javascript now and coming from the background of Java. In Java we have overloaded constructors wherein, at compile time, the compiler will decide which version of constructor to be called. In case of Javascript, we can have only one…
zilcuanu
  • 3,451
  • 8
  • 52
  • 105
13
votes
3 answers

Creating variables for destructured objects in addition to their properties

I have: const { state: { mode } } = this console.log(mode) //'mode' console.log(state) //undefined I want to declare the state variable as well. Is there a way to destructure this without breaking it into two statements? const { state } =…
pailhead
  • 5,162
  • 2
  • 25
  • 46
13
votes
2 answers

Reduce object thought object.entries

I have this kind of object I want to get new object with keys that have "exist === true" const someObj = { super: { exist: true }, photo: { exist: true }, request: { exist: false …
user1898714
  • 141
  • 1
  • 1
  • 6
13
votes
1 answer

calling an async function in the constructor.

getUser is an async function? if it is going to take longer time to resolve? is it going to always return the right value in my someotherclass. class IdpServer { constructor() { this._settings = { // some identity server…
hashbytes
  • 769
  • 1
  • 8
  • 26