10 examples of 'jquery create array' in JavaScript

Every line of 'jquery create array' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your JavaScript code is secure.

All examples are scanned by Snyk Code

By copying the Snyk Code Snippets you agree to
this disclaimer
120function makeArray(o) {
121 var arr = [];
122
123 for (var i = 0, len = o.length; i < len; i++) {
124 var node = o[i];
125
126 // 过滤掉注释等节点
127 if (node.nodeType === 1) {
128 arr.push(node);
129 }
130 }
131
132 return arr;
133}
Important

Use secure code every time

Secure your code as it's written. Use Snyk Code to scan source code in minutes – no build needed – and fix issues immediately. Enable Snyk Code

1409function initCloneArray(array) {
1410 var length = array.length,
1411 result = new array.constructor(length);
1412
1413 // Add array properties assigned by `RegExp#exec`.
1414 if (length && typeof array[0] == 'string' && hasOwnProperty.call(array, 'index')) {
1415 result.index = array.index;
1416 result.input = array.input;
1417 }
1418 return result;
1419}
274function ARRAY(aElements, aParts) {
275 var aResult = [];
276
277 aElements.forEach(function(fnArgument, i) {
278 aResult[i] = fnArgument(aParts);
279 });
280 return aResult;
281}
36function makeArray(arr) {
37 return Array.isArray(arr) ? arr : [arr]
38}
64function makeArray (arr) {
65 if (!arr || typeof arr.length === 'undefined') {
66 return [ arr ];
67 }
68 return arr;
69}
7function makeArray(arr) {
8 if(!arr){
9 return [];
10 }
11 return angular.isArray(arr) ? arr : [arr];
12}
11function initCloneArray(array) {
12 const length = array.length
13 const result = new array.constructor(length)
14
15 // Add properties assigned by `RegExp#exec`.
16 if (length && typeof array[0] == 'string' && hasOwnProperty.call(array, 'index')) {
17 result.index = array.index
18 result.input = array.input
19 }
20 return result
21}
44function cloneArray(array) {
45 var length = array ? array.length : 0,
46 result = Array(length);
47
48 while (length--) {
49 result[length] = array[length];
50 }
51 return result;
52}
132function toArray(arrayLike) {
133 var result = [];
134
135 for (var i = 0; i < arrayLike.length; i++) {
136 result.push(arrayLike[i]);
137 }
138
139 return result;
140}
27function array(n) {
28 for(i=0;i<n;i++) this[i]=0;
29 this.length=n;
30}

Related snippets