Home >Web Front-end >JS Tutorial >How to declare array length in jquery
How to declare the length of an array in jquery: directly use the [new Array(n)] statement to define an array of length n, declare an array with 10 elements, the code is [var a = new Array (10);].
The operating environment of this tutorial: windows7 system, jquery3.2.1 version, DELL G3 computer.
Recommended: jquery video tutorial
How to declare the array length in jquery:
Use new Array directly (n)
The statement can define an array of length n
Declare an array with 10 elements
var a = new Array(10);
At this time, the memory space has been opened for a, containing 10 elements , call it by adding [subscript] to the array name, such as a[2], but the element has not been initialized at this time, and the call will return undefined.
Related free learning recommendations: javascript(Video)
The above is the detailed content of How to declare array length in jquery. For more information, please follow other related articles on the PHP Chinese website!