gpt4 book ai didi

jquery 扩展返回 init 函数

转载 作者:行者123 更新时间:2023-12-01 03:12:15 25 4
gpt4 key购买 nike

这是一个错误吗?

var x = $.extend({});
var y = $.extend({},{});

alert($.isEmptyObject(y)); //true as expected
alert($.isEmptyObject(x)); //false?

如果不是,为什么这是预期的行为,为什么没有记录?

最佳答案

它实际上记录在 docs for extend 中:

If only one argument is supplied to $.extend(), this means the target argument was omitted. In this case, the jQuery object itself is assumed to be the target. By doing this, you can add new functions to the jQuery namespace. This can be useful for plugin authors wishing to add new methods to JQuery.

因此,x 实际上是扩展 jQuery 对象,当然它还包括其所有正常函数,包括 init。

关于jquery 扩展返回 init 函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25570226/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com