Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

JavaScript JavaScript Loops, Arrays and Objects Tracking Multiple Items with Arrays Two-Dimensional Arrays

Manish Giri
Manish Giri
16,266 Points

Why is arrays being referred to as lists?

In the 2-Dimensional Arrays video(and even before), Dave talks about "arrays" as "lists". Are they really the same?

I know they are the same in Python, but different in Java. So perhaps it's not a best idea to not use them interchangeably.

6 Answers

I can understand that Dave is just using "list" with its normal "non-programming" definition. However, I do agree with the original poster that it might have been clearer and, perhaps, preferable to choose a description with less potential to lead to confusion if a student were coming from (or going to), for instance, the python, php or java track.

huckleberry
huckleberry
14,636 Points

Sooooo, are those two examples of a language that I assumed, in my answer above, have an actual thing in them called "lists"?

Cheers,

Huck - :sunglasses:

Java and Python both have data collections called lists that differ from arrays. PHP also has a method called list which operates on arrays (so the concept of list is different there as well). In addition, most object oriented languages have the concept of a "linked list" which is a data structure used for arranging collections of data. All of these languages have the concept of "list" which may be related to "array" but differ from array in meaningful ways.

Using list as a synonym for array with the frequency it's repeated in the lectures is totally fine if the only programming language tracks a student plans on learning are the JavaScript focused ones. However, I can see how it'd cause at least some confusion for novice programmers should they be coming from, or proceeding to, the other language tracks.

huckleberry
huckleberry
14,636 Points

Ah ok, cool, thanks for the explanation :)

Dave McFarland
STAFF
Dave McFarland
Treehouse Teacher

Sorry for all of the confusion. Yes, I'm using "list" as a metaphor not a technical term. JavaScript has fewer data structures than other languages, and it's true that "list" has a specific technical meaning in many other programming languages -- Python, R, Java, to name a few. I've found that those new to programming, "array" isn't immediately accessible or understandable, so I'll often use "list" instead. But I can certainly understand the confusion for those coming from another language where a "list" and an "array" are two technically different data structures.

Gunhoo Yoon
Gunhoo Yoon
5,027 Points

As far as I know they are used as synonyms in most situation. However, I've found that in Java, Perl world and possibly other area they are treated different. I don't know anything about Java and Perl so if you are interested you can check these out and dig further maybe?

array and list in Java From Stackoverflow

array and list in Perl From some blog

huckleberry
huckleberry
14,636 Points

It's just how he's saying it. I mean, that's what they're most commonly used for... keeping an ordered grouping of things that, by their very nature, are listy lol.

I gather that in other languages there are actual objects called lists? JavaScript doesn't have anything called lists so I guess it's just fine to refer to it as a list if you're just shooting the breeze. But really, that's all an array is. It's a numerically ordered list of values. Because it doesn't have key value pairs in the sense that an object does, it's just a numerical(indexed) group(list) of stuff you put in there so... yeah, it iiiis a list in that sense so...

Cheers,

Huck - :sunglasses:

In Python arrays are in fact called lists. If you think of the nature of an array, it can be considered a list. While JavaScript != Python, I believe the word "List" is as technical as the word "Array."

In the first video of the course, Dave says,

  • "It's like a blank piece of paper that I can write my shopping list on."
  • "Now you know what an array is. It's really just a list of items."