我刚刚遇到以下代码:
function showMatch(str, reg) {
var res = [], matches
while(true) {
matches = reg.exec(str)
if (matches === null) break
res.push(matches[0])
if (!reg.global) break
alert(res)
}
谁能解释一下第二行吗?做
var res = [], matches
equal
var res=[]; res=matches
or
var res=[]; var matches=[]
?
我想第二个答案是正确的?我觉得这有点令人困惑......
它相当于
var res = [];
var matches;
where matches
is undefined
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)