Is there any way to create a List of objects in JS/JQuery as I do in C#?
I just want to dynamically add objects to a list as I do in C#. Like:
List<string> myList = new List<string>();
myList.add("myString");
Is there any way to achieve the same thing in Javascript? I don't care if the list is typed or not. I just want the data structure.
Thanks!
Yes, use an array.
Example:
var myList = [];
myList.push("myString");
In C# arrays are fixed size, but in Javascript you can add items to them just like lists in C#.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.