<分区>
下面代码中的双箭头参数是什么意思?
const update = x => y => {
// Do something with x and y
}
与下面的相比有何不同?
const update = (x, y) => {
// Do something with x and y
}
谢谢!
<分区>
下面代码中的双箭头参数是什么意思?
const update = x => y => {
// Do something with x and y
}
与下面的相比有何不同?
const update = (x, y) => {
// Do something with x and y
}
谢谢!
最佳答案
让我们重写它们“旧式”,第一个是:
const update = function (x) {
return function(y) {
// Do something with x and y
};
};
第二个是:
const update = function (x, y) {
// Do something with x and y
};
如您所见,它们非常不同,第一个返回“中间”函数,而第二个是具有两个参数的单个函数。
关于javascript - ES6 双箭头参数(即 const update = x => y => { } ),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46365288/