1. 复制N个字符 String.prototype.repeat = function(num){ return (new Array(++num)).join(this); } var a = 'A'; a.repeat(5); //'AAAAA' 2. 替代if…else… var result; result = isTrue ? something : anotherthing; result = something || anotherthing; result = somethin…