3
Lo-Dash에서 thisArg를 어떻게 사용합니까? 체인과 결합 할 수 있습니까? 나는 그들의 문서에 하나를 찾을 수 없습니다로 Lo-Dash에서 thisArg를 사용하는 방법?
_.map(collection, [callback=identity], [thisArg])
Creates an array of values by running each element in the collection through the callback. The callback is bound to thisArg and invoked with three arguments; (value, index|key, collection).
If a property name is provided for callback the created "_.pluck" style callback will return the property value of the given element.
If an object is provided for callback the created "_.where" style callback will return true for elements that have the properties of the given object, else false.
Aliases
_.collect
Arguments
collection (Array|Object|string): The collection to iterate over.
[callback=identity] (Function|Object|string): The function called per iteration. If a property name or object is provided it will be used to create a ".pluck" or ".where" style callback, respectively.
[thisArg] (*): The this binding of callback.
Returns
(Array): Returns a new array of the results of each callback execution.
예
은 평가 될 것입니다 : 이것은 그들의 문서에서 thisArg를 사용하는 예입니다.
변수 'this'바인딩을 사용하려면이 인수를 사용할 수 있습니까? 예 : 'O = {foo : function() {return this.bar; }, bar : 42}; A = [O, O]; _.map (A, O.foo, _.identity)'? (마지막 표현식이 예상대로 작동하지 않습니다.) –
github에서 직접 문제를 열었습니다 : https://github.com/lodash/lodash/issues/803 –