摘要: 1functionselectFrom(lowerValue,upperValue){2varchoices=upperValue-lowerValue+1;3returnMath.floor(Math.random()*choices+lowerValue);4}56varnum=selectFrom(2,10);7console.log(num);89varcolors=["red","green","blue","yellow","black","purple",&qu 阅读全文
posted @ 2012-03-15 16:17 小猩猩君 阅读(162) 评论(0) 推荐(0) 编辑
摘要: 1varstringValue="yellow";2console.log(stringValue.localeCompare("brick"));3console.log(stringValue.localeCompare("yellow"));4console.log(stringValue.localeCompare("zoo"));chrome下brick显示为23,其他浏览器均为1 阅读全文
posted @ 2012-03-15 14:37 小猩猩君 阅读(1515) 评论(0) 推荐(0) 编辑
摘要: 1functionhtmlEscape(text){2returntext.replace(/[<>"&]/g,function(match,pos,originalText){3switch(match){4case"<":5return"&lt;";6case">":7return"&gt;";8case"&":9return"&amp;";10case"\"":11r 阅读全文
posted @ 2012-03-15 14:13 小猩猩君 阅读(220) 评论(0) 推荐(0) 编辑