arrow-functions

    -3热度

    1回答

    ​​ 我当前的代码如下,但当前缓冲区告诉我这是语法错误:意外的令牌如果。 // write the correct arrow function here var my_function = some_array => some_array.map((currentValue, index) => if(index % 2 === 0) currentValue + 1; else curren

    4热度

    1回答

    它我的理解是,这并不工作(这是一个人为的例子 - 见RxJS什么我实际运行): function Foo() { this.name = 'Johnny Cash' } Foo.prototype.who =() => { console.log(this.name) // undefined }; var foo = new Foo(); foo.who()

    3热度

    1回答

    我有一个简单的函数(一个阵营组件内): getInitialState: function() { return { text: this.props.text } } 但我想胖arrowify它: getInitialState:() => { text: this.props.text } 除了我得到一个错误,因为毕竟胖箭头手段{一段代码返回

    2热度

    2回答

    什么是“let x = something1 => something2 => something3”? 我有这段代码,我不明白它做了什么。 const myReducers = {person, hoursWorked}; const combineReducers = reducers => (state = {}, action) => { return Object.keys(

    0热度

    2回答

    在使用箭头函数调用函数时,我非常困惑this的值。让我们以我的例子: var obj = { property: 5, func1: function() { console.log(this.property); }, func2:() => { console.log(this.property); } } 当我把这个

    3热度

    1回答

    注意,相关Value of this inside object method? 鉴于 var obj = { property: 5, func1: function() { console.log(this.property); }, func2:() => { console.log(this.property); }

    1热度

    2回答

    考虑我们有一个数组,其中包含我们希望从对象数组中提取其值的对象的所有属性。每个对象的形式。 var keys = ['name', 'age']; 假设我们有一群学生。学生对象看起来像: var student = {name:"Sarah", age:"20", address:"123 Main St."}; 我们有一群学生。 使用下面的代码来提取我们感兴趣的每个学生的属性和值。我们感

    1热度

    1回答

    我被一本JS书中的例子困住了。这是一个箭头功能。工作正常,但函数引用了哪些变量?它如何知道如何处理“a,b”? 我不明白是怎么回事幕后... const arr = [{ name: "Suzanne" }, { name: "Jim" }, { name: "Trevor" }, { name: "Amanda" }

    0热度

    2回答

    我正在尝试使用更高阶的函数,试图成为更好的JavaScript开发人员。 我从下面的代码中得到的错误是TypeError: myArray.reduce is not a function我发誓我遵循正确的设计模式。 function myFunction(myArray) { return myArray.reduce((prev, curr) => prev * curr); }

    2热度

    1回答

    我不能左右的箭头功能的最后办法很好的理解有: 没有命名重复arguments-箭头功能不能有重复的 命名参数是严格模式或非严格模式,与nonarrow 函数不同,只有在严格的 模式下才能有重复的命名参数。 以上段落摘自Nicholas C. Zakas在'Function'一章中写的Book“Understanding ECMAScript 6”一书。 根据上面的描述,我知道箭头函数没有像其他函数