gpt4 book ai didi

javascript - 有没有更快的方法来编写条件语句?

转载 作者:行者123 更新时间:2023-11-30 06:57:08 25 4
gpt4 key购买 nike

我有这样的声明:

 if(window.location.hash != '' && window.location.hash != '#all' && window.location.hash != '#')

我可以写成只需要提及一次 window.location.hash 吗?

最佳答案

最明显的方法是:

var h = window.location.hash;
if (h != '' && h != '#all' && h != '#')

关于javascript - 有没有更快的方法来编写条件语句?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4191433/

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