$ .noop()在jQuery 1.4中的真正用途是什么? [英] What real purpose does $.noop() serve in jQuery 1.4?

查看:134
本文介绍了$ .noop()在jQuery 1.4中的真正用途是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

关于jQuery 1.4的发行说明,我来到了acrosss $。noop () 即:

Pouring over the release notes regarding jQuery 1.4, I came acrosss $.noop() which is:


描述:空函数。 (在1.4中添加)

Description: An empty function. (added in 1.4)

如果希望传递一个什么都不做的函数,可以使用这个空函数。

也许我在这里遗漏了一些深刻的东西,但传递一个空函数究竟是什么实际用途?

Perhaps I'm missing something profound here, but what exactly is a practical use of passing around an empty function?

代码示例表示赞赏。

推荐答案

此功能是由于使用<时嵌入式系统的性能问题而提出的code> $。ajax ,在jQuery-Dev邮件列表中报告。您可以看到主题

This function was proposed due to performance issues on embedded systems when using $.ajax, reported on the jQuery-Dev mailing list. You can see the thread.

基本上,他们更愿意引入并使用这个空函数,而不是声明空的匿名函数。

Basically, they preferred to introduce and use this single empty function, rather than declaring empty anonymous functions all around.

现在,此函数在 ajax 内部使用,事件 offset modules。

Now this function is internally used in the ajax, event and offset modules.

你可以看看提交时它也被引入。

You can give a look to the commit when it was introduced also.

这篇关于$ .noop()在jQuery 1.4中的真正用途是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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