JS implements a method for randomly generating strings (length can be specified)
1. Define a random interception string const _charStr = ‘abacdefghjklmnopqrstuvwxyzABCDEFGHJKLMNOPQRSTUVWXYZ0123456789’; 2. Define the randomly generated index function /** * 随机生成索引* @param min 最小值* @param max 最大值* @param i 当前获取位置*/ function RandomIndex(min, max, i){ let index = Math.floor(Math.random()*(max-min+1)+min), numStart = _charStr.length – 10; //如果字符串第一位是数字,则递归重新获取if(i==0&&index>=numStart){ index = RandomIndex(min, … The post JS implements a method to randomly […]
JS implements a method for randomly generating strings (length can be specified) Read More »