Most of what I know is Javascript. I believe "Lists" are the closest thing Dart has to Arrays, but are they technically the same thing? Is it wrong to think of them as Arrays? Similarly, would Maps be considered Objects? I realize there are likely differences, but would it be "wrong" to make that comparison?
JavaScript Array
objects are similar to Dart growable List
objects. Both can be added to and accessed by index. Dart lists can only be accessed by index, where JavaScript lists are full JavaScript objects (see below), it just has a magic length
property that is only updated when using integer-named properties. In practice, use a Dart List
where you would have used a JavaScript Array
.
JavaScript Object
s are a combination of multiple things. They are mappings from string names to values - that part is best simulated by a Dart Map<String, Object>
. They also allow prototype based inheritance, and if you are using that, you probably want to define a Dart class instead. As a data structure, use a Dart Map
where you would have used a JavaScript {}
object.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With