React, why use super(props) inside of ES6 class constructor? [duplicate]

This question already has answers here: What’s the difference between “super()” and “super(props)” in React when using es6 classes? (10 answers) Closed 5 years ago. I realize the super keyword can be used to call functions in a parent component. However, I’m not totally clear why you would use the super keyword in the example … Read more

What do curly braces around a variable in a function parameter mean

I saw this code on a package: const SortableList = SortableContainer(({items}) => { return ( <ul> {, index) => <SortableItem key={`item-${index}`} index={index} value={value} /> )} </ul> ); }); What is happening to items by putting curly braces around it in the function parameters? Answer This is destructuring assignment syntax. As another example, the following two … Read more

Destructure Spread off Import ES6

import {Component, …actions} from ‘../MyModule’; Seems to be throwing a linting error. Is there a reason why you can’t “spread” on an ES6 import statement? Answer ES6 import syntax is not destructuring, it’s as simple as that. The syntax starts with {, but its format is entirely different, and the way that it is handled … Read more

Prevent use of unsupported JavaScript features in IE11 using ESLint?

I have an existing ESLint configuration with “ecmaVersion” set to “5” that I want to modify to allow the use of let and const which are ES6 features. There are mostly* supported in Internet Explorer 11. However, I want to reject the use of any ES6 features that aren’t supported in IE11, e.g. classes. How … Read more

Unable to import webpack-bundled UMD library as an ES6 import

I’ve authored a javascript library using Webpack. The entrypoint someClass.js looks like this: import x from ‘./x’ /* several more imports here */ class SomeClass {} export default SomeClass; My webpack config that bundles this library is as follows: module.exports = { entry: ‘./someClass.js’, output: { path: __dirname, filename: ‘lib.js’, library: ‘lib’, libraryTarget: ‘umd’, }, … Read more

arguments.callee alternative in es6 for determining caller function [duplicate]

This question already has answers here: How do you find out the caller function in JavaScript when use strict is enabled? (5 answers) Closed 1 year ago. In framework, I’m developing, I’ve constructed mechanism, that allowed to define private and protected properties and methods. The only ability, I found in ES5 specifications for doing that … Read more

How to include additional ES6 sources in Angular app

I have a custom mode module written in ES6 syntax that I am including in my angular application and I am encountering problems (from uglifyjs) when I attempt to build the app with the -prod flag enabled: Unexpected token: punc () This is an angular 5 app using angular-cli 1.7.4 also. The entry file for … Read more

“Holes” in array when use es6 spread operator on string with emojis

Why when I try split string with emoji(s) using spread(…) operator I get “holes” in result array? Example: […’💪’] // -> [“💪”, hole] Also more emojis creates more “holes”: […’💪💪’] // -> [“💪”, “💪”, hole, hole] Screenshot from Chrome v71.0.3578.98: Answer Certainly this is a bug. As a workaround, Array.from() works identically except it isn’t … Read more