请解释下划线.js的_.identity(value)的用法 [英] Please explain usage of _.identity(value) of underscore.js

查看:409
本文介绍了请解释下划线.js的_.identity(value)的用法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

请解释下划线.js的 _ .identity(value)的用法。无法从文档中了解它( http://underscorejs.org/#identity )。

Please explain usage of _.identity(value) of underscore.js. Not able to understand it from the documentation ( http://underscorejs.org/#identity ).

你能提供一些使用它的例子吗?

Can you provide some example of its usage?

推荐答案

这实际上是一个不 - 操作功能。它返回传递给它的任何值。

It's essentially a no-operation function. It returns the value of whatever was passed into it.

关于它在库中用作默认迭代器的部分意味着在其他函数中可能有一个可选的iterator参数(可能用作应用于某种数组的每个元素的函数),如果没有传递迭代器参数,库将使用这个no-op迭代器而不是元素数组将保持不变。

The part about it being used as a "default iterator" within the library itself means that in other functions which may have an optional "iterator" parameter (which is likely used as a function to apply to each element of an array of some kind), if no iterator parameter is passed, the library will use this "no-op" iterator instead and the elements of the array will remain unchanged.

这篇关于请解释下划线.js的_.identity(value)的用法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆