location.href属性与location.assign()方法 [英] location.href property vs. location.assign() method
本文介绍了location.href属性与location.assign()方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
使用 location.href = url
与使用 location.assign(url)<之间的JavaScript内存消耗是否有任何特定优势/劣势
?
我想我想知道是否需要更多内存来访问该方法而不是设置属性。
I guess I'm wondering if it takes more memory to access the method as opposed to setting the property.
推荐答案
我一直使用并且从未遇到过问题:
i always used and never had problems with:
location.href = url;
调用函数应该比访问属性稍慢,但就内存而言,不应该有我的拙见有很大不同
calling a function should be slightly slower than accessing the property but in terms of memory there should not be a big difference in my humble opinion
这篇关于location.href属性与location.assign()方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文