Programming Basics #32 Array Behaviour


http://learn-share.net/programming-array-behaviour/
Programming Course. The Basics of Programming.
#32 Array Behaviour

Learn to code.
Array behaviour

In java_script, arrays are objects. We will talk about more objects, but for now, it just means, more than containers of data.

Now, arrays are smart, they can tell information about them selves, they have behaviour and can do things.

What this means. We kind have seen this already.
Let’s say i create a variable that is just a string. We’ve seen than we can use dot length property, to find information about this string. In this case to pop up an alert message.

Now, we can find this kind of format to find information about arrays.

Let’s say we use the shorthand format to create an array with five elements, ranging from the position 0 to position 4.

We can do the something very similarly that i do with the string. Calling my array dot length. And in this case returning an pop up message with the word five.

Now, he knows is length is five. That is the length of the entire array. There five elements in it, although bare in mind, the higher index is the number 4.

But we using the same dot length property.

Is smart enough that when we say, dot length in a string, is how many characters on a string.