JavaScript函数声明的这种方式称为什么?(var)= > { }(复制)

时间:2022-08-26 23:23:18

This question already has an answer here:

这个问题已经有了答案:

upon reading the latest NodeJS docs I encountered a new way of declaring a function:

在阅读最新的NodeJS文档时,我发现了一种声明函数的新方法:

fs.unlink('/tmp/hello', (err) => {
  if (err) throw err;
  console.log('successfully deleted /tmp/hello');
});

Source: https://nodejs.org/api/fs.html#fs_file_system

来源:https://nodejs.org/api/fs.html fs_file_system

Now I want to know how this (var) => { <functon-content> } type declaration is called, so that I can research more on it.

现在我想知道这个(var) => {< function -content>}类型声明是如何被调用的,这样我可以对它做更多的研究。

I have not yet found anything online regarding this topic. :(

关于这个话题,我还没有在网上找到任何东西。:(

1 个解决方案

#1


4  

It's a feature of the ECMAScript 6 called Arrow Function: https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Functions/Arrow_functions

它是ECMAScript 6的一个特性,称为箭头函数:https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Functions/Arrow_functions。

An arrow function expression (also known as fat arrow function) has a shorter syntax compared to function expressions and lexically binds the this value (does not bind its own this, arguments, super, or new.target). Arrow functions are always anonymous.

与函数表达式相比,箭头函数表达式(也称为fat arrow函数)的语法更短,并且在词汇上绑定这个值(不绑定它自己的this、parameters、super或new.target)。箭头函数总是匿名的。

#1


4  

It's a feature of the ECMAScript 6 called Arrow Function: https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Functions/Arrow_functions

它是ECMAScript 6的一个特性,称为箭头函数:https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Functions/Arrow_functions。

An arrow function expression (also known as fat arrow function) has a shorter syntax compared to function expressions and lexically binds the this value (does not bind its own this, arguments, super, or new.target). Arrow functions are always anonymous.

与函数表达式相比,箭头函数表达式(也称为fat arrow函数)的语法更短,并且在词汇上绑定这个值(不绑定它自己的this、parameters、super或new.target)。箭头函数总是匿名的。