Basic JavaScript - Accessing Nested Arrays - Why calling arrays as objects in the instruction?

Hello ! The instruction says , " Using dot and bracket notation, set the variable secondTree to the second item in the trees list from the myPlants object."

My question is why it is describing ‘myPlants’ variable as an object ? Isn’t it a list as it uses third bracket first ? Similarly shouldn’t ‘trees’ described as a list be an object in accordance with what we have learned so far ? Can someone clarify, kindly ?

Hi there and welcome to our community!

Technically, myPlants is an array of objects.
The array myPlants contains a tree object, which contains a property called list, which is in array form.

(A Javascript array is similar, but not identical, to a Python list, so the terms cannot be used interchangeably).

Slightly confusing terminology perhaps, but I hope that makes sense!

1 Like

Sorry … I wanted to say array . But called it as list. It was a mistake. But my question remains the same. Please, read it here now. I have corrected it -

Hello ! The instruction in the lesson says , " Using dot and bracket notation, set the variable secondTree to the second item in the trees list from the myPlants object."

My question is why it is describing ‘myPlants’ variable as an OBJECT ? Isn’t it an ARRAY as it uses Third Bracket First ? Has there been a mistake ? If so then they can correct it.

1 Like

Is this the Challenge you are working on?

Technically, arrays are objects. I think the wording can be clearer though.

2 Likes

How is technically arrays are objects ? Can you explain?

console.log(typeof([]));

What does this say in the console?

3 Likes

Maybe I will try it later and let you know. Many many thanks for your efforts.

1 Like

There is no good reason to call it an object. Especially not in the context of this challenge. It should be changed.

I made a PR, the wording is odd as well so I tried to fix it.

Hi @istiaqueRezaAuyon

Arrays are a special type of object.

To quote from fCC’s Basic JavaScript module:

Declare JavaScript data type variables
In computer science, data is anything that is meaningful to the computer. JavaScript provides eight different data types which are undefined, null, boolean, string, symbol, bigint, number, and object.

So of the eight data types, only object can be used when describing an array.

1 Like