DEV Community

Discussion on: When is an array, not an array?

Collapse
 
dance2die profile image
Sung M. Kim • Edited

Thanks Joe for the post.

Is an "array data structure" a superset of "array type"?
or are they not related at all?

Collapse
 
thejoezack profile image
Joe Zack

Types refer to the language implimentations, basically it's whatever looks like an array and
a specific language says is an array.

The data structure definition is more formal: contiguos memory allocation of the same sized element so you can achieve random access (as in, lookup any) in constant time.

In some languages, array types are implimented with array data structures (like C#) but JavaScript is a bit more complicated because it has to support a flexible language specification.

Collapse
 
dance2die profile image
Sung M. Kim • Edited

Borrowing C# analogy,

Types refer to an interface while data structure is a type of implementation implementing the interface.

Am I getting close to the truthiness? 😆

Thread Thread
 
thejoezack profile image
Joe Zack

I like it!