Access Array Data with Indexes

Published: 24 March 2023
on channel: HighTech6839v
25
0

JavaScript arrays are zero-indexed: the first element of an array is at index 0, the second is at index1 , and so on — and the last element is at the value of the array's length property minus 1.

What is a var in JavaScript? var is the keyword that tells JavaScript you're declaring a variable. x is the name of that variable. = is the operator that tells JavaScript a value is coming up next. 100 is the value for the variable to store.

What is a const in JavaScript? The const declaration creates block-scoped constants, much like variables declared using the let keyword. The value of a constant can't be changed through reassignment (i.e. by using the assignment operator), and it can't be redeclared (i.e. through a variable declaration).

What is an array in JavaScript? Arrays are used to store multiple values in a single variable. This is compared to a variable that can store only one value. Each item in an array has a number attached to it, called a numeric index, that allows you to access it. In JavaScript, arrays start at index zero and can be manipulated with various methods.

If you console.log(myArray[0]); you'll see the number 50 by itself.
If you console.log(myArray[1]); you'll see the number 60 by itself.
If you console.log(myArray[2]); you'll see the number 70 by itself.


On this page of the site you can watch the video online Access Array Data with Indexes with a duration of hours minute second in good quality, which was uploaded by the user HighTech6839v 24 March 2023, share the link with friends and acquaintances, this video has already been watched 25 times on youtube and it was liked by 0 viewers. Enjoy your viewing!