function(size) randomString { size = size || 6; var chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789', // 62个字符 maxNum = chars.length, ret = ''; while (size > 0) { ret += chars.charAt(Math.floor(Math.random() * maxNum)); size--; } return ret; }