Advanced JavaScript Training
Accessing Array Element

Accessing Array Element

  <p class='lg:w-1/2 w-full leading-relaxed text-gray-500 w-1/2 p-0.5' style='text-align: left; margin-right: 1in;'>
       <p style='text-align: left;'> You can access elements in an array using their index, with the first element at index 0</p>


<pre style='text-align: left;'>

let fruits = ['apple', 'banana', 'cherry’]; console.log(fruits[0]); // Outputs 'apple’ console.log(fruits[1]); // Outputs 'banana'

Have a doubt?
Post it here, our mentors will help you out.