일상적인 단선 솔루션.
배열의 값은 총 랜덤이므로이 스 니펫을 사용하면 달라집니다.
소문자로 된 임의의 문자가있는 배열 (길이 10)
Array.apply(null, Array(10)).map(function() { return String.fromCharCode(Math.floor(Math.random() * (123 - 97) + 97)); })
[ 'k', 'a', 'x', 'y', 'n', 'w', 'm', 'q', 'b', 'j']
0에서 99 사이의 임의의 정수가있는 배열 (길이 10)
Array.apply(null, Array(10)).map(function() { return Math.floor(Math.random() * 100 % 100); })
[86, 77, 83, 27, 79, 96, 67, 75, 52, 21]
배열 임의 날짜 (10 년 전부터 지금까지)
Array.apply(null, Array(10)).map(function() { return new Date((new Date()).getFullYear() - Math.floor(Math.random() * 10), Math.floor(Math.random() * 12), Math.floor(Math.random() * 29) )})
[2008-08-22T21 : 00 : 00.000Z, 2007-07-17T21 : 00 : 00.000Z,
2015-05-05T21 : 00 : 00.000Z, 2011-06-14T21 : 00 : 00.000Z,
2009-07-23T21 : 00 : 00.000Z, 2009-11-13T22 : 00 : 00.000Z,
2010-05-09T21 : 00 : 00.000Z, 2008-01-05T22 : 00 : 00.000Z,
2016-05-06T21 : 00 : 00.000Z, 2014-08-06T21 : 00 : 00.000Z]
배열 (길이 10) 임의의 문자열
Array.apply(null, Array(10)).map(function() { return Array.apply(null, Array(Math.floor(Math.random() * 10 + 3))).map(function() { return String.fromCharCode(Math.floor(Math.random() * (123 - 97) + 97)); }).join('') });
[ 'cubjjhaph', 'bmwy', 'alhobd', 'ceud', 'tnyullyn', 'vpkdflarhnf', 'hvg', 'arazuln', 'jzz', 'cyx']
여기에서 찾을 수있는 다른 유용한 정보 https://github.com/setivolkylany/nodejs-utils/blob/master/utils/faker.js