Sobes.tech
Middle

How to access the first element of an array?

sobes.tech AI

Answer from AI

In most programming languages, the first element of an array is accessed by index 0. For example, if there is an array arr, then the first element will be arr[0].

Example in JavaScript:

const arr = [10, 20, 30];
console.log(arr[0]); // Outputs 10

This rule applies in languages such as C, C++, Java, JavaScript, Python (lists), Go, and many others.

How to access the first element of an array? — QA /… - sobes.tech