ecmascript-2015

Using `super` within an arrow function within an arrow function within a method

▼魔方 西西 提交于 2019-11-30 08:15:11
I'm trying to figure out whether some behavior I'm seeing in Node v4.1.1 (V8 v4.5.103.33) regarding super and arrow functions is specified behavior , and if so (or indeed, if not), where it is in the specification that it says it should (or should not) work in the various cases I have. In brief: Using super in an arrow function ( inner ) inside another arrow function ( outer ) inside a method works unless outer has arguments or variables inner references, even if inner references arguments or variables of method . I want to know what the spec says about that: Should it work all the time, even

Why can functions be called without parentheses when using template strings? [duplicate]

坚强是说给别人听的谎言 提交于 2019-11-30 04:42:22
This question already has an answer here: Backticks calling a function 2 answers I have a simple logging function: function log(str) { console.log('logged: ', str); } If I call it without parentheses (currently using Chrome's dev tools) and pass in a template string, like this: log`foo` The output is: logged: ["foo", raw: Array[1]] If I call it with parentheses, log(`foo`) The output is: logged: foo Why does calling a function using a template string an no parentheses work in Javascript? What is happening that causes the result to be different from calling it with parentheses? Sampson The

Using `super` within an arrow function within an arrow function within a method

别来无恙 提交于 2019-11-29 11:10:42
问题 I'm trying to figure out whether some behavior I'm seeing in Node v4.1.1 (V8 v4.5.103.33) regarding super and arrow functions is specified behavior , and if so (or indeed, if not), where it is in the specification that it says it should (or should not) work in the various cases I have. In brief: Using super in an arrow function ( inner ) inside another arrow function ( outer ) inside a method works unless outer has arguments or variables inner references, even if inner references arguments or

Why can functions be called without parentheses when using template strings? [duplicate]

自作多情 提交于 2019-11-29 02:03:32
问题 This question already has answers here : Backticks calling a function (2 answers) Closed 2 years ago . I have a simple logging function: function log(str) { console.log('logged: ', str); } If I call it without parentheses (currently using Chrome's dev tools) and pass in a template string, like this: log`foo` The output is: logged: ["foo", raw: Array[1]] If I call it with parentheses, log(`foo`) The output is: logged: foo Why does calling a function using a template string an no parentheses

Why to you have to specify the type of the export (let, var, const…) in ES2015?

[亡魂溺海] 提交于 2019-11-27 03:36:18
问题 As I'm reading here, ES2015 allows you to export var , const , let , function , class and default . export var myVar1 = ...; export let myVar2 = ...; export const MY_CONST = ...; export function myFunc() { ... } export function* myGeneratorFunc() { ... } export class MyClass { ... } But I don't understand why. In my layman opinion, there should be named exports and default exports . The type of what you are exporting doesn't seem to matter. I mean, when you export default , do you specify the