我刚刚发布了一个要点:
https://gist.github.com/2228570
var out = ''; function doWhat(){ out += '<li>'; console.log(out === '<li>'); // at this point,out will equal '<li>' return ''; } out += doWhat(); console.log(out,out === '<li>'); // I expect out to == '<li>',but it's actually an empty string!?
这个行为是奇怪的,有没有人有解释?这是google的难处.如果你使用out =或out = out,它也没有区别.
编辑:@paislee做了一个JSFiddle,演示了如何做一个单独的行,它的行为如预期:http://jsfiddle.net/paislee/Y4WE8/