Home  >  Article  >  Web Front-end  >  How to declare array length in jquery

How to declare array length in jquery

coldplay.xixi
coldplay.xixiOriginal
2020-12-24 14:42:192481browse

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);].

How to declare array length in jquery

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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn