Interactive Design 2 Learning Diary 02

JavaScript Array and Objects

Arrays and objects are two most commonly seen data arrangement features in lots of different programming languages, and such functions can also be found in JS. In order to understand the differences between these two arrangement features, the references article gives two really useful and understandable analogy. Accessing data that are stored in a array is like reading a book, all you need to know is what exact chapter number you want to read, and then you can find the corresponding caption of that chapter in the index page. Array can be accessed in the same way, except the starting number starts with zero. Comparing to array, accessing data that are stored in objects can be analogize as reading a newspaper. If you know the section name, then you can access the content in that section pretty easily when you are searching through using the name. Same thing applies to objects. You can access the data in an object by knowing the key, such as "class.number", which is a good example that can be found commonly in object-orientated programming. These two types of data storing methods together can create lots of flexible combinations. Such as knowing the user's log number which is stored in array, and then access some personalized data that are stored in a object with key values such as "age", "sex", etc. These explainations are insipiring and gave me more idea of the differences and possible utilizations of these two types of storing methods.

JavaScript Arrays and Objects Are Just Like Books and Newspapers

Write a Comment