There is no list data type in JavaScript. The List type is to solve the problem of immutable array length, but JavaScript does not have this problem. Most of the functions of List are also available in JavaScript arrays.
The operating environment of this tutorial: Windows 10 system, JavaScript version 1.8.5, Dell G3 computer.
Does JavaScript have a list type?
JavaScript can define array types, but there is no so-called List type.
There is no need for the List type to exist in JavaScript. JAVA's List type is to solve the problem of immutable array length, but JavaScript does not solve this problem. JavaScript arrays have variable lengths and have many practical methods that can be used. They are much more flexible than JAVA arrays. Most of the functions of JAVA's List are also available in JavaScript arrays.
There are several ways to define arrays in JavaScript:
var arr = []; //Define an empty array
var arr = [1,2,3];//Define an array with elements
The above is the detailed content of Is there a list type in javascript?. For more information, please follow other related articles on the PHP Chinese website!