Most voted "ecmascript-6" questions
This tag is NOT synonymous with [javascript] and [typescript] tags. Also NOT to be used when the doubt is about technical problems of use (difficulties) or third party libraries, it should be used only for doubts about the specifications of the sixth edition (ES6/Ecmascript® 2015).
Learn more…132 questions
Sort by count of
-
37
votes3
answers9049
viewsWhat is a Transpilation?
I started reading one article on Ecmascript 6 and I came across the term Transpilation, which in Portuguese would be Transpilation. In addition to this, I noticed that other articles use this term.…
-
34
votes1
answer36730
viewsJavascript: Differences between import and require
I know that import and require are used in Javascript to import functions or objects from third parties. Code snippets like: import Library from 'some-library'; or const Library =…
-
23
votes2
answers2921
viewsWhat does the "=>" operator mean?
I was seeing some solutions in Javascript and in one case I saw this command line: return args.reduce((s, v) => s + v, 0);. But I don’t know what the operator means =>. What is his function?…
-
23
votes1
answer433
viewsTransponders in Ecmascript
What are the allowed characters, or what is allowed, within a name (known as "identifier") in the Ecmascript 6? Has rules between identifiers and keywords???…
-
20
votes3
answers2999
viewsWhat is the difference between for...of and for.. in?
I was taking a look at that question from the SOEN and there I saw this for..of. I’ve never seen that before in Javascript. This is a new resource and we can implement it reliably, or we should…
-
20
votes2
answers5648
viewsWhat is Ecmascript 2015 (ES6) specification?
I recently started a project with Cordova + Ionic and, at a certain point, I entered an impasse in which I found the affirmative that the framework follows the "latest" web standards such as the new…
-
19
votes1
answer403
viewsHow does Symbol work on ES6?
In the new Javascript specification Ecmascript (ES6) a new primitive type was created called Symbol() what use it is?…
-
17
votes3
answers4038
viewsWhat is the definition of verbose code? And why is it interesting to reduce it?
I have recently heard about verbose code reduction (next to the term Boiler Plate code), and also by studying ES6 by falling into Arrow-functions. Would you like a clearer definition of what verbose…
javascript terminology encoding-style ecmascript-6asked 7 years, 11 months ago Denis Bernardo 1,770 -
16
votes2
answers2766
viewsWhat is a string template (literal string declared with "`" grave accent) for in Javascript?
I was fiddling with the Chrome console these days and then, as my keyboard was disfigured, I accidentally typed the grave accent ` instead of single quotes ' to create a string. The interesting…
-
15
votes1
answer3438
viewsvar, const or Let? Which to use?
I recently discovered the existence of let and const but now I’m in doubt which one to use constantly? And why I never see codes with let or const?…
-
14
votes1
answer300
viewsWhat are the improvements that the Spread Operator implementation will bring to javascript?
I’m taking a look at the new Eatures of the EcmaScript6 and saw that the Spread Operator. He looks very similar to variadic function PHP (which also uses Spread Operator). Here’s an example of what…
-
13
votes1
answer545
viewsHow does ES7 async/await work?
ES7 allows you to use a new syntax to work with Promises known as async/await functions. How I can use these functions and how they are compared to functions that use Promises to process sequential…
javascript asynchronous ecmascript-6 promises async-awaitasked 8 years, 3 months ago Gabriel Gartz 5,624 -
13
votes2
answers234
viewsReference loss in function call
Setting: class ClassName { constructor(service, params) { this.service = service; this.params = params; this.save(params.id); } save(id) { const { service, onSuccess, onError } = this; return…
-
9
votes2
answers119
viewsES6 classes do not allow property declaration?
I was experimenting with the class declaration syntax ES6/ES-2015, and could not declare properties, only methods: class Teste { constructor() { } metodo() { } // não funciona: //propriedade: valor…
-
9
votes3
answers619
viewsWhat is String.raw for in Javascript?
Well, that’s the question. I would like to know what the method is for String.raw in Javascript. I saw something in the documentation of MDN, but I did not understand very well the use Has something…
-
9
votes1
answer812
viewsWhat does "Tree-Shaking" mean?
I closely follow the entire development of the Angular. I know the third generation of the rendering engine (the Ivy, code name for Render 3) will be released soon. Overall, the objectives for this…
-
9
votes1
answer941
viewsWhat is the difference between Object.assign and spread Operator?
What is the detailed difference of using Object.assign and the Operator spread (...) for spreading properties of objects? For example, when editing an object for new values, it is the same output:…
-
8
votes2
answers169
viewsDoubt in the statement between Arrow expression and function expression of an event
I have the following code snippet: self.addEventListener('push', event => {"code here"}); My question is... this writing format is equal to: self.addEventListener('push', function(event) {"code…
-
8
votes1
answer162
viewsAnimations in high quality
We all know that animations on the web are a little bit eye friendly, when opening a side menu, whether in mobile or in desktop, you can only see part of your drive, giving the impression of a…
-
8
votes4
answers711
viewsWhy are literal objects declared with const in Javascript currently?
Because of Ecmascript 6 I see examples that declare literal objects with the reserved word const. Code example: // Versão utilizada atualmente const obj = { x: 'example' }; // Versão utilizada…
-
8
votes1
answer147
viewsHow to use a predefined interpolation in Javascript
I was reading in ES6 documentation about interpolation (or Template strings) and saw that I can create "escaped templates", as in the example below: class InvalidParamError extends Error { static…
-
7
votes1
answer253
viewsDifference between Yield and Yield* operators in Ecmascript 6.0 "Harmony"?
I’m studying the use of generators in Ecmascript 6.0 "Harmony". I have already managed to understand its basic functioning, like the statement through the syntax function* () { ... } and value…
-
7
votes1
answer353
viewsHow does the syntax of Tagged template strings: fn`text ${10} text`work?
One of the novelties of ES6 are strings template. How this new syntax applied to functions works? For example, what does this code? applyStyle ` #minhaDiv { background-color: ${'#ccf'}; width:…
-
7
votes2
answers331
viewsSemicolon(;) in Ecmascript 6 is no longer required?
When using Ecmascript 6 (ES6) it is no longer necessary to use semicolons (;) at the end of each code line?
-
7
votes2
answers252
viewsApply immutability effect to objects in a Javascript class ECMA6
To illustrate, I have the following class: class LavarCarro { constructor(cor, placa, data_entrada) { this._cor = cor; this._placa = placa; this._data_entrada = data_entrada; Object.freeze(this); //…
-
6
votes0
answers252
viewsCreating a multi-level structure for components in Angularjs + ES6
I am creating a robust application using Angularjs on ES6 and I need to assemble a structure so that the logic of the application components is organized. Basically, my application works with…
-
6
votes5
answers2427
viewsGet clicked element position
I have a list of entries and one of the attributes of that item is a delete button. By clicking the button I want to know the position of the line clicked inside the list. When knowing the position…
-
6
votes2
answers218
viewsAlternative to __filename and __dirname in Node.js with Ecmascript Modules
From more recent versions of Node.js, you can use the Ecmascript Modules standard (instead of the ancient Commonjs) for importing modules via extension .mjs or field type defined as module in the…
-
6
votes1
answer44
viewsWhat exactly does Rest syntax return, just the elements or some special object?
Doing some exercises, I realized that it is possible to use the map function in a Rest that apparently only returns pure elements. also realized that it is not possible to apply a typeof nor…
-
5
votes1
answer760
viewsUse of IIFE in ES6
In ES5 it is considered a good practice to use IIFE to force a local scope in our code. EX: (function(){ // some code })(); In ES6 this is still necessary? Once keyword has been introduced let for…
-
5
votes1
answer64
viewsFunction generator returns Undefined
Consider the following function: function* gerador() { let foo = yield "a" let bar = yield "b" let baz = yield "c" return `${foo} ${bar} ${baz}` } let gen = gerador(); console.log(gen.next());…
-
5
votes2
answers449
viewsQuestions about block scope in Javascript
The doubts are as follows: What is the difference between block scope and function scope in Javascript? The idea of block scope arose in Ecmascript 6 with let and const?…
-
5
votes1
answer36
viewsWhy can’t I use add operator in function with this?
Why when I run the following code: function Pessoa(){ this.idade = 0; console.log(this.idade); setTimeout(function() { this.idade++; console.log(this.idade); }, 2000); } new Pessoa(); My way out is…
-
4
votes1
answer1081
viewsDeclaration of key variables in Javascript
I recently saw a type of Javascript code, in some examples of Electron, which I believe is part of ES6. These are variable statements in the following format: const electron = require('electron');…
-
4
votes1
answer349
viewsHow to implement a destructor in Javascript?
In languages such as C++, we have the possibility to declare a destructor for a class, so that certain actions are performed when an object of that class is destroyed. How to do this in Javascript?…
-
4
votes1
answer107
viewsIs there still reason to use var in Javascript?
ES6 introduced the Keywords let and const for variable declaration. There is still reason to use var? If yes, in which scenarios to use?
-
4
votes0
answers44
viewsPart of my code doesn’t seem to pass through Babel before arriving at Uglify
I’m not managing to generate the production build of my application with Laravel Mix. When trying to generate the build npm tells me there was an error trying to run Uglifyjs: /js/app.js from…
-
4
votes4
answers2052
viewsIs Ecmascript 6 supported by current browsers?
Can Ecmascript 6 features available in Javascript already be used in a way that is supported by current browsers? I wonder if this version is already supported as a whole (and not just specific…
-
4
votes2
answers459
viewsHow does Hoisting work on ES6?
For example, using var, by calling the function below in this way: function funcao(){ console.log(foo); var foo = "mensagem"; } funcao(); Will return undefined because of the Hoisting, that moves…
-
4
votes2
answers353
viewsWhy does Typescript when compiled convert "Let" to "var" in variables?
If let variavel = "valor"; is also compatible with JavaScript, because in the compilation of Typescript, it turns to var variavel = "valor"? Take the test right here: function foo(){ var x = 1; let…
javascript typescript ecmascript-6 variable-declarationasked 6 years, 3 months ago Ivan Ferrer 12,096 -
4
votes2
answers201
viewsConditionally add elements into the Javascript Array
When I try to merge two objects using the operator spread conditionally, it works perfectly with both conditions 'true' and 'false': let condition1 = false; let condition2 = true; let obj1 = { key1:…
-
3
votes2
answers96
viewsHow to make Netbeans recognize the ES2015 syntax?
How to use the Netbeans with the ES2015? I’ve done some testing with Netbeans 8.0.1 and 8.0.2, but does not recognize the new syntax: let, const, etc..…
-
3
votes3
answers86
viewsJavascript comparison
well I want to know if my comparison has how to be improved, I want to make the code shorter (dry) const teste = function(a){ if(a != null && a != undefined && a != ""){…
-
3
votes1
answer71
viewsWhat is and what is the "Proxy" Javascript constructor for?
I know the builder Proxy was added in Javascript version 6 (ES6). My questions are: What is? What is its main purpose and how to use it?
-
3
votes1
answer36
viewsThis parameter outside of expected inside an anonymous function
I made a code to train handling Arrays and Javascript. This is part of the code: function Playlist (nome ='Playlist'){ const musicas = []; function addMusicas(...novasMusicas){…
-
3
votes1
answer116
viewsHow to transform an array recursively?
I have the following array: let exemplo = [{ alarm: { title: "Pai", id: "1" }, children: [], parent: "", }, { alarm: { title: "Filho", id: "2", }, parent: "Pai", children: [], }, { alarm: { title:…
-
3
votes1
answer56
viewsWhat is the reason for using "super()" before creating daughter class variables?
I found this question which speaks almost of the same subject but her focus is on access to parent class methods. And my doubt is to know why the use of super() before the declaration of variables…
-
2
votes2
answers98
viewsUse the number of characters obtained in a regular expression sentence in string substitution
I am doing a Markdown parser as part of a study on regular expressions, and I would like to use the amount of characters obtained in an excerpt of the expression, as a basis for string substitution,…
javascript regex parser ecmascript-6 ecmascript-5asked 9 years, 3 months ago Daniel de Andrade Varela 267 -
2
votes0
answers99
viewsSet the ion-radio as required
I am mounting a dynamic form using ionic2, but multiple choice components do not accept the property required how would I do that on Ionic? The component I’m trying to put property required is the…
-
2
votes3
answers89
viewsError calling a secondary method via CALLBACK: Uncaught Typeerror: Cannot read Property 'secondarily named' of Undefined
With Javascript (Ecmascript-6), when calling a method via callback, if this method uses another method the following error occurs: Uncaught Typeerror: Cannot read Property…