Questions tagged as 'ecmascript-6'

1
answer

Function 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()); console.log(gen.next()); console...
asked by 16.07.2017 / 19:48
3
answers

Comparison in JavaScript

Well, I want to know if my comparison can be improved, I want to leave the code shorter. const teste = function(a){ if(a != null && a != undefined && a != ""){ console.log('e diferente') }else{ co...
asked by 25.03.2018 / 05:24
1
answer

What does "Tree-Shaking" mean?

I closely follow all the development of the Angular. I know that the third generation of the rendering engine ( Ivy , codenamed for Render 3) will launch soon. Overall, the goals for this new renderer are: Asyoucanseeinthediagramabove,oneoft...
asked by 26.07.2018 / 04:07
1
answer

How to implement a destructor in JavaScript?

In languages like C ++, we have the possibility to declare a destructor for a class, so that certain actions are performed when an object of this class is destroyed. How to do this in JavaScript? For example: class minhaClasse { constru...
asked by 06.07.2016 / 15:32
1
answer

How does the syntax of Tagged template strings: fn'text $ {10} text 'work?

One of the novelties of ES6 is template strings. How does this new syntax apply to functions? For example, what does this code do?: applyStyle ' #minhaDiv { background-color: ${'#ccf'}; width: ${50}px; height: ${40}px; fon...
asked by 21.11.2016 / 21:19
1
answer

Why does TypeScript when compiled, convert "let" to "var" in variables?

If let variavel = "valor"; is also supported in JavaScript , because in TypeScript compilation, it transforms to var variavel = "valor" ? Take the test right here : function foo(){ var x = 1; let y = 3; if (true){...
asked by 20.08.2018 / 22:14
0
answers

Creating a multi-level structure for components in AngularJS + ES6

I'm creating a robust application using AngularJS on ES6 and need to mount a structure so that the logic of the application components is organized. Basically, my application works with numerous modules, and these are structured in packages for...
asked by 21.12.2016 / 16:38
2
answers

What's the difference between these uses of the setTimeout () function?

What's the difference between using setTimeout() so setTimeout(()=>this.logicaRotacao(), 3000) And so? setTimeout(this.logicaRotacao(), 3000)     
asked by 15.11.2018 / 18:36
1
answer

Declaration of variables with keys in Javascript

Recently I've seen a JavaScript code type, in some examples of Electron, which I believe to be part of ES6. They are variable declarations in the following format: const electron = require('electron'); // Module to control application life. co...
asked by 29.06.2016 / 19:22
1
answer

This outside-expected parameter within an anonymous function

I made a code to train Arrays and JavaScript manipulation. Here's part of the code: function Playlist (nome ='Playlist'){ const musicas = []; function addMusicas(...novasMusicas){ novasMusicas.forEach(function(musica){...
asked by 15.12.2018 / 16:00