Dealing with Arrays in javascript

in #html5 years ago

Hello, hivers. I'm here to give a detailed explanation on how to get an item by index number, and also delete an item on the list.
Alright, let's begin.

Example

An Array can have different values
String = "Hive",
Number = 2
Object = {post},
Boolean = True/False

{"hiveBlog":[ "Post", "proposals", "witnesses", "dApps" ]}
when trying to access the list of items in the array, one could use

x =Object.hiveblog

Note: list of items in an array are been numbered from zero index upwards, For Example

[ "Post", "proposals", "witnesses", "dApps" ]

0 = post,
1 = proposals
2 = witnesses
3 = dApps

So when accessing the items individually one can use
x =Object.hiveblog[0]
The above result would be = post

While also when trying to access the last item on the array it's going to be
x =Object.hiveblog[3]
which is = dApps

To delete among the list of items in the array one can use
delete Object.hiveBlog[1];
Which is going to remove proposals from the list

stay tuned, more to come concerning arrays