ecmascript-6 Questions
3
Solved
I am looking for an elegant way to import all named exports without having to import the default as well.
In one file I am exporting many named constants plus a default:
// myModule.js
const myDe...
Talon asked 30/5, 2017 at 9:54
8
I am using the following logic to get the i18n string of the given key.
export function i18n(key) {
if (entries.hasOwnProperty(key)) {
return entries[key];
} else if (typeof (Canadarm) !== 'und...
Lulu asked 2/9, 2016 at 0:57
10
In a React functional component, which is the better approach to set default props, using Component.defaultProps, or using the default parameters on the function definition, examples:
Default prop...
Astrict asked 12/12, 2017 at 14:11
3
if i write such code in webstorm
export class someOne {
constructor(param) {
this.test = param;
}
useTest(){
return this.test;
}
}
console.log(new someOne(123).useTest());
and mouseove...
Bilestone asked 16/4, 2016 at 23:18
34
I'm using ArcGIS JSAPI 4.12 and wish to use Spatial Illusions to draw military symbols on a map.
When I add milsymbol.js to the script, the console returns error
Uncaught SyntaxError: Cannot use i...
Bifid asked 3/10, 2019 at 3:20
9
Solved
I'm using repl.it/languages/javascript.
Do I have to convert it to an object before I print it out?
I've tried
const mapObject = new Map();
mapObject.set(1, 'hello');
console.log...
Bullough asked 8/8, 2017 at 14:30
2
I have noticed that the formating of several countries (Poland, Russia, France and more) follows a strange behaviour. The format starts to apply on values with more that 4 digits. You can see it in...
Ddene asked 8/2, 2021 at 14:11
2
Solved
Is there a terse es6 functional way to group items by type in that it's immutable?
accounts.json
[
{"account": {"name": "Bob's credit", "type": "credit", "id": "1"}},
{"account": {"name": "sav...
Contemptible asked 30/3, 2018 at 13:28
2
CommonJS import const webpack = require('webpack'); works fine, but ES6 import webpack from 'webpack'; no.
From Webpack Documentation:
Version 2 of webpack supports ES6 module syntax natively.
...
Tutelary asked 23/5, 2018 at 16:47
2
Solved
I am developing some tests with Jest for a Node.js backend and I need to check out some values that come from a third party. In some cases those values can come as a boolean or as null.
Right now ...
Juieta asked 31/5, 2018 at 10:7
3
Solved
According to ES6 shorthand initialiser, following 2 methods are same:
In ES5
var person = {
name: "Person",
greet: function() {
return "Hello " + this.name;
}
};
In ES6
var person = {
nam...
Selfpronouncing asked 1/9, 2016 at 5:31
4
Solved
I am using Javascript ES6 features in a node.js application:
class pairKey {
constructor(x_pos, y_pos) {
this._X = x_pos;
this._Y = y_pos;
}
get x() {
return this._X;
}
set x(x_pos) {
this._X...
Sentinel asked 11/8, 2015 at 19:59
26
Solved
I use the flag --experimental-modules when running my Node application in order to use ES6 modules.
However when I use this flag the metavariable __dirname is not available. Is there an alternative...
Epley asked 14/10, 2017 at 13:17
5
In CustomDecorator, how to access a service instance defined in Nest.js?
export const CustomDecorator = (): MethodDecorator => {
return (
target: Object,
propertyKey: string | symbol,
des...
Outworn asked 30/8, 2018 at 22:56
11
I have come through many tutorials and screenshots of JS Code in Visual Studio Code editor consisting of formatted arrows seen for arrow functions.
Which extension/theme/symbol set is required to g...
Steersman asked 6/1, 2020 at 19:20
2
Solved
I want to be able to proxy all methods of a class inside the constructor of a class itself.
class Boy {
constructor() {
// proxy logic, do something before each call of all methods inside class
...
Quaquaversal asked 6/11, 2021 at 1:34
5
Solved
JavaScript's class syntax, added in ES6, apparently makes it legal to extend null:
class foo extends null {}
new foo();
Some Googling reveals that it was suggested on ES Discuss that such declara...
Takao asked 16/12, 2016 at 17:6
20
I build a expressJs app by ES6 and I got the below error:
(node:4132) ExperimentalWarning: The ESM module loader is experimental.
internal/modules/run_main.js:54
internalBinding('errors').trigger...
Masturbate asked 18/4, 2020 at 15:27
4
Solved
To learn rxjs im playing around with it.
My code:
// RxJS v6+
import { withLatestFrom, map } from 'rxjs/operators';
import { interval } from 'rxjs';
const source = interval(1000);
const example ...
Lucarne asked 2/12, 2019 at 10:34
3
Solved
How to get a last element of ES6 Map/Set without iterations(forEach or for of) pass through a full length of the container?
Domini asked 18/6, 2015 at 16:50
3
I have the following module class and to make it work similar to non module functional javascript, I have to call a function to bind all the class member functions to the correct this scope and I h...
Arenicolous asked 25/12, 2023 at 4:50
5
I have Set() object with three key value
var myset =new Set();
myset.add('first','This is first value');
myset.add('second','This is second value');
myset.add('third','This is third value');
Usi...
Juni asked 12/7, 2018 at 11:44
4
Solved
There are already a lot of cool features in ES6/ES7 for defining Javascript objects. However, the following pattern is common in Javascript:
const obj = {
requiredKey1: ...,
requiredKey2...
Larhondalari asked 19/12, 2017 at 17:18
6
Solved
Are there any limits to what types of values can be set using const in JavaScript, and in particular, functions? Is this valid? Granted it does work, but is it considered bad practice for any reaso...
Otherdirected asked 9/10, 2015 at 14:22
6
Solved
I'm new to Gulp and trying to automate some tasks. Here's my environment setup: npm version: 8.1.0, node version 17.0.1, gulp CLI version 2.3.0 and gulp version 4.0.2
And here's my gulpfile.js:
// ...
Novah asked 6/11, 2021 at 9:21
© 2022 - 2024 — McMap. All rights reserved.