-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patharray.js.html
86 lines (64 loc) · 6.67 KB
/
array.js.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>JSDoc: Source: array.js</title>
<script src="scripts/prettify/prettify.js"> </script>
<script src="scripts/prettify/lang-css.js"> </script>
<!--[if lt IE 9]>
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<link type="text/css" rel="stylesheet" href="styles/prettify-tomorrow.css">
<link type="text/css" rel="stylesheet" href="styles/jsdoc-default.css">
</head>
<body>
<div id="main">
<h1 class="page-title">Source: array.js</h1>
<section>
<article>
<pre class="prettyprint source linenums"><code>/*
数组相关
*/
/**
* [genDateArray description] 创建过去七天的数组
* @return {Array} 过去七天的数组(Date类型)
*/
function genDateArray() {
return [...Array(7).keys()].map(days => new Date(Date.now() - 86400000 * days));;
}
/**
* [getRandomItem description] 获取随机数组成员
* @param arr {Array} 数组
* @return {Any} 随机数组成员
*/
function getRandomItem(arr) {
const randomItem = arr[Math.floor(Math.random() * arr.length)];
return randomItem;
}
/**
* [countItemNum description] 统计数组中各成员个数
* @param arr {Array} 待统计数组
* @return {Object} 统计结果
*/
function countItemNum(arr) {
const count = arr.reduce((t, c) => {
t[c] = t[c] ? ++ t[c] : 1;
return t;
}, {});
return count;
}
</code></pre>
</article>
</section>
</div>
<nav>
<h2><a href="index.html">Home</a></h2><h3>Global</h3><ul><li><a href="global.html#addQuote">addQuote</a></li><li><a href="global.html#addStyle">addStyle</a></li><li><a href="global.html#appendQuery">appendQuery</a></li><li><a href="global.html#bs2">bs2</a></li><li><a href="global.html#bs4">bs4</a></li><li><a href="global.html#bs8">bs8</a></li><li><a href="global.html#byteCount">byteCount</a></li><li><a href="global.html#CanvasTest">CanvasTest</a></li><li><a href="global.html#cloneDeep">cloneDeep</a></li><li><a href="global.html#copyTextToClipboard">copyTextToClipboard</a></li><li><a href="global.html#countItemNum">countItemNum</a></li><li><a href="global.html#cssTest">cssTest</a></li><li><a href="global.html#dateToString">dateToString</a></li><li><a href="global.html#debounce">debounce</a></li><li><a href="global.html#digitUppercase">digitUppercase</a></li><li><a href="global.html#escapeHTML">escapeHTML</a></li><li><a href="global.html#escapeRegExp">escapeRegExp</a></li><li><a href="global.html#formatDate">formatDate</a></li><li><a href="global.html#formatDuration">formatDuration</a></li><li><a href="global.html#genDateArray">genDateArray</a></li><li><a href="global.html#generateDaysArray">generateDaysArray</a></li><li><a href="global.html#genRandomColor">genRandomColor</a></li><li><a href="global.html#genRandomHEX">genRandomHEX</a></li><li><a href="global.html#genRandomId">genRandomId</a></li><li><a href="global.html#genRandomNum">genRandomNum</a></li><li><a href="global.html#genRandomString">genRandomString</a></li><li><a href="global.html#genStarScore">genStarScore</a></li><li><a href="global.html#genTimeStamp">genTimeStamp</a></li><li><a href="global.html#getBrowserName">getBrowserName</a></li><li><a href="global.html#getCookie">getCookie</a></li><li><a href="global.html#getCurrentPath">getCurrentPath</a></li><li><a href="global.html#getDateDiff">getDateDiff</a></li><li><a href="global.html#getDevice">getDevice</a></li><li><a href="global.html#getInputIndex">getInputIndex</a></li><li><a href="global.html#getJsDir">getJsDir</a></li><li><a href="global.html#getLocation">getLocation</a></li><li><a href="global.html#getNetType">getNetType</a></li><li><a href="global.html#getPageHeight">getPageHeight</a></li><li><a href="global.html#getPageViewWidth">getPageViewWidth</a></li><li><a href="global.html#getPageWidth">getPageWidth</a></li><li><a href="global.html#getRandomItem">getRandomItem</a></li><li><a href="global.html#getRequestParams">getRequestParams</a></li><li><a href="global.html#getRoundNum">getRoundNum</a></li><li><a href="global.html#getSearchParams">getSearchParams</a></li><li><a href="global.html#getStringLength">getStringLength</a></li><li><a href="global.html#getSystem">getSystem</a></li><li><a href="global.html#getType">getType</a></li><li><a href="global.html#getUrlState">getUrlState</a></li><li><a href="global.html#hexMd5">hexMd5</a></li><li><a href="global.html#hexToRgba">hexToRgba</a></li><li><a href="global.html#initRequestAnimationFrame">initRequestAnimationFrame</a></li><li><a href="global.html#isContains">isContains</a></li><li><a href="global.html#isDigit">isDigit</a></li><li><a href="global.html#isEndsWith">isEndsWith</a></li><li><a href="global.html#isStartsWith">isStartsWith</a></li><li><a href="global.html#loadScript">loadScript</a></li><li><a href="global.html#loadStyle">loadStyle</a></li><li><a href="global.html#localStorageTest">localStorageTest</a></li><li><a href="global.html#move">move</a></li><li><a href="global.html#numberUpperFormat">numberUpperFormat</a></li><li><a href="global.html#numOfComma">numOfComma</a></li><li><a href="global.html#numOfComma2">numOfComma2</a></li><li><a href="global.html#objToQuery">objToQuery</a></li><li><a href="global.html#pad">pad</a></li><li><a href="global.html#pseudoHack">pseudoHack</a></li><li><a href="global.html#regularExpressionTest">regularExpressionTest</a></li><li><a href="global.html#remInit">remInit</a></li><li><a href="global.html#repeat">repeat</a></li><li><a href="global.html#replaceAll">replaceAll</a></li><li><a href="global.html#reverse">reverse</a></li><li><a href="global.html#sessionStorageTest">sessionStorageTest</a></li><li><a href="global.html#setCookie">setCookie</a></li><li><a href="global.html#showDomOutline">showDomOutline</a></li><li><a href="global.html#stringToDate">stringToDate</a></li><li><a href="global.html#stripHTMLTags">stripHTMLTags</a></li><li><a href="global.html#stripScripts">stripScripts</a></li><li><a href="global.html#SVGTest">SVGTest</a></li><li><a href="global.html#throttle">throttle</a></li><li><a href="global.html#timeAgo">timeAgo</a></li><li><a href="global.html#toAscii">toAscii</a></li><li><a href="global.html#toHump">toHump</a></li><li><a href="global.html#trim">trim</a></li><li><a href="global.html#truncate">truncate</a></li><li><a href="global.html#ucfirst">ucfirst</a></li><li><a href="global.html#webpAnimataionSupportDetect">webpAnimataionSupportDetect</a></li></ul>
</nav>
<br class="clear">
<footer>
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.10</a> on Mon Feb 14 2022 16:57:07 GMT+0800 (China Standard Time)
</footer>
<script> prettyPrint(); </script>
<script src="scripts/linenumber.js"> </script>
</body>
</html>