for (var i = 0; i < str.length; i++) { alert(str.charAt(i));}
如果警报的顺序无关紧要,请使用以下命令:
var i = str.length;while (i--) { alert(str.charAt(i));}var str = 'This is my string';function matters() { for (var i = 0; i < str.length; i++) { alert(str.charAt(i)); }}function dontmatter() { var i = str.length; while (i--) { alert(str.charAt(i)); }}<p>If the order of alerts matters, use <a href="#" onclick="matters()">this</a>.</p><p>If the order of alerts doesn't matter, use <a href="#" onclick="dontmatter()">this</a>.</p>
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)