[英]converting double fat arrow to standard function
While reading the following article: https://medium.com/javascript-scene/master-the-javascript-interview-what-is-a-pure-function-d1c076bec976 and I got to the following piece of code: 在阅读以下文章时: https : //medium.com/javascript-scene/master-the-javascript-interview-what-is-a-pure-function-d1c076bec976 ,我得到了以下代码:
const highpass = (cutoff, value) => value >= cutoff;
Which outputs: 哪个输出:
highpass(5, 123); // true
highpass(5, 5); // true
highpass(5, 1); // false
Since I'm not an expert on fat arrow function I tried to convert them into simple functions, but the second fat arrow and the result are confusing me, here's what I have so far: 由于我不是胖箭头功能的专家,因此我尝试将它们转换为简单的函数,但是第二个胖箭头及其结果使我感到困惑,这就是我到目前为止所拥有的:
function highpass(cutoff, value)
{
return function(value)
{
return function(cutoff)
{
????????
}
};
};
What am I missing here? 我在这里想念什么?
That is equivalent to 那相当于
const highpass = function(cutoff, value){ return value >= cutoff; } console.log(highpass(2, 3))
在Question的代码中只有一个箭头函数, >=
大于或等于运算符
function highpasss(value, cutoff) {return value >= cutoff}
The "second" is a comparison, not a function “第二”是一个比较,而不是一个函数
const highpass = (cutoff, value) => value >= cutoff;
translates to 转换为
const highpass = function(cutoff, value) {
return value >= cutoff;
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.