我有这样的声明:
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/