简体   繁体   English

Arrow函数如何在ECMAScript6中工作

[英]How does the Arrow function work in ECMAScript6

I am working on mathematical program and ready to implement new feature of ECMAScript6 Arrow . 我正在研究数学程序,并准备实施ECMAScript6 Arrow新功能。 Which is very similar to Lambda expression in C# . 这与C# Lambda表达式非常相似。

let square = y => y * y;
console.log(square(4));

I achieved my goal after using Arrow function but still confuse how the Arrow function is works. 使用Arrow函数后,我实现了目标,但仍然对Arrow函数的工作方式感到困惑。

Is it work like Lambda expression.Can anyone guide me on that. 它像Lambda表达式一样工作吗?有人可以指导我吗?

Thanks 谢谢

It's essentially doing this: 本质上是这样做的:

var square = function(y) {
  return y * y;
}.bind(this);

where this is bound to the outer scope. 其中this被绑定到外部范围。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM